hcju/stacksqa huggingface dataset:
Taking base change, this immediately reduces to the following problem: given a valuation ring $R$ with fraction field $K$ and an algebraic space $X$ proper over $R$ and a coherent $\mathcal{O}_{X_K}$-module $\mathcal{F}_K$, show there exists a finitely presented $\mathcal{O}_X$-module $\mathcal{F}$ flat over $R$ whose generic fibre is $\mathcal{F}_K$. Observe that by Flatness on Spaces, Theorem \ref{spaces-flat-theorem-finite-type-flat} any finite type quasi-coherent $\mathcal{O}_X$-module $\mathcal{F}$ flat over $R$ is of finite presentation. Denote $j : X_K \to X$ the embedding of the generic fibre. As a base change of the affine morphism $\Spec(K) \to \Spec(R)$ the morphism $j$ is affine. Thus $j_*\mathcal{F}_K$ is quasi-coherent. Write $$ j_*\mathcal{F}_K = \colim \mathcal{F}_i $$ as a filtered colimit of its finite type quasi-coherent $\mathcal{O}_X$-submodules, see Limits of Spaces, Lemma \ref{spaces-limits-lemma-directed-colimit-finite-type}. Since $j_*\mathcal{F}_K$ is a sheaf of $K$-vector spaces over $X$, it is flat over $\Spec(R)$. Thus each $\mathcal{F}_i$ is flat over $R$ as flatness over a valuation ring is the same as being torsion free (More on Algebra, Lemma \ref{more-algebra-lemma-valuation-ring-torsion-free-flat}) and torsion freeness is inherited by submodules. Finally, we have to show that the map $j^*\mathcal{F}_i \to \mathcal{F}_K$ is an isomorphism for some $i$. Since $j^*j_*\mathcal{F}_K = \mathcal{F}_K$ (small detail omitted) and since $j^*$ is exact, we see that $j^*\mathcal{F}_i \to \mathcal{F}_K$ is injective for all $i$. Since $j^*$ commutes with colimits, we have $\mathcal{F}_K = j^*j_*\mathcal{F}_K = \colim j^*\mathcal{F}_i$. Since $\mathcal{F}_K$ is coherent (i.e., finitely presented), there is an $i$ such that $j^*\mathcal{F}_i$ contains all the (finitely many) generators over an affine \'etale cover of $X$. Thus we get surjectivity of $j^*\mathcal{F}_i \to \mathcal{F}_K$ for $i$ large enough.
Let $(T \to B, \mathcal{F})$ be an object of $\Cohstack_{X/B}$. We claim \begin{enumerate} \item[(a)] $(T \to B, \pi_{T, *}\mathcal{F})$ is an object of $\Cohstack_{Y/B}$ and \item[(b)] for $T' \to T$ we have $\pi_{T', *}(X_{T'} \to X_T)^*\mathcal{F} = (Y_{T'} \to Y_T)^*\pi_{T, *}\mathcal{F}$. \end{enumerate} Part (b) guarantees that this construction defines a functor $\Cohstack_{X/B} \to \Cohstack_{Y/B}$ as desired. \medskip\noindent Let $i : Z \to X_T$ be the closed subspace cut out by the zeroth fitting ideal of $\mathcal{F}$ (Divisors on Spaces, Section \ref{spaces-divisors-section-fitting-ideals}). Then $Z \to B$ is proper by assumption (see Derived Categories of Spaces, Section \ref{spaces-perfect-section-proper-over-base}). On the other hand $i$ is of finite presentation (Divisors on Spaces, Lemma \ref{spaces-divisors-lemma-fitting-ideal-of-finitely-presented} and Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-closed-immersion-finite-presentation}). There exists a quasi-coherent $\mathcal{O}_Z$-module $\mathcal{G}$ of finite type with $i_*\mathcal{G} = \mathcal{F}$ (Divisors on Spaces, Lemma \ref{spaces-divisors-lemma-on-subscheme-cut-out-by-Fit-0}). In fact $\mathcal{G}$ is of finite presentation as an $\mathcal{O}_Z$-module by Descent on Spaces, Lemma \ref{spaces-descent-lemma-finite-finitely-presented-module}. Observe that $\mathcal{G}$ is flat over $B$, for example because the stalks of $\mathcal{G}$ and $\mathcal{F}$ agree (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-stalk-push-closed}). Observe that $\pi_T \circ i : Z \to Y_T$ is quasi-finite as a composition of quasi-finite morphisms and that $\pi_{T, *}\mathcal{F} = (\pi_T \circ i)_*\mathcal{G})$. Since $i$ is affine, formation of $i_*$ commutes with base change (Cohomology of Spaces, Lemma \ref{spaces-cohomology-lemma-affine-base-change}). Therefore we may replace $B$ by $T$, $X$ by $Z$, $\mathcal{F}$ by $\mathcal{G}$, and $Y$ by $Y_T$ to reduce to the case discussed in the next paragraph. \medskip\noindent Assume that $X \to B$ is proper. Then $\pi$ is proper by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-universally-closed-permanence} and hence finite by More on Morphisms of Spaces, Lemma \ref{spaces-more-morphisms-lemma-characterize-finite}. Since a finite morphism is affine we see that (b) holds by Cohomology of Spaces, Lemma \ref{spaces-cohomology-lemma-affine-base-change}. On the other hand, $\pi$ is of finite presentation by Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-finite-presentation-permanence}. Thus $\pi_{T, *}\mathcal{F}$ is of finite presentation by Descent on Spaces, Lemma \ref{spaces-descent-lemma-finite-finitely-presented-module}. Finally, $\pi_{T, *}\mathcal{F} $ is flat over $B$ for example by looking at stalks using Cohomology of Spaces, Lemma \ref{spaces-cohomology-lemma-stalk-push-finite}.
Let $\mathcal{I} \subset \mathcal{O}_Y$ be the sheaf of ideals cutting out $X$ as a closed subspace of $Y$. Recall that $\pi_*$ induces an equivalence between the category of quasi-coherent $\mathcal{O}_X$-modules and the category of quasi-coherent $\mathcal{O}_Y$-modules annihilated by $\mathcal{I}$, see Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-i-star-equivalence}. The same, mutatis mutandis, is true after base by $T \to B$ with $\mathcal{I}$ replaced by the ideal sheaf $\mathcal{I}_T = \Im((Y_T \to Y)^*\mathcal{I} \to \mathcal{O}_{Y_T})$. Analyzing the proof of Lemma \ref{lemma-coherent-functorial} we find that the essential image of $\Cohstack_{X/B} \to \Cohstack_{Y/B}$ is exactly the objects $\xi = (T \to B, \mathcal{F})$ where $\mathcal{F}$ is annihilated by $\mathcal{I}_T$. In other words, $\xi$ is in the essential image if and only if the multiplication map $$ \mathcal{F} \otimes_{\mathcal{O}_{Y_T}} (Y_T \to Y)^*\mathcal{I} \longrightarrow \mathcal{F} $$ is zero and similarly after any further base change $T' \to T$. Note that $$ (Y_{T'} \to Y_T)^*( \mathcal{F} \otimes_{\mathcal{O}_{Y_T}} (Y_T \to Y)^*\mathcal{I}) = (Y_{T'} \to Y_T)^*\mathcal{F} \otimes_{\mathcal{O}_{Y_{T'}}} (Y_{T'} \to Y)^*\mathcal{I}) $$ Hence the vanishing of the multiplication map on $T'$ is representable by a closed subspace of $T$ by Flatness on Spaces, Lemma \ref{spaces-flat-lemma-F-zero-closed-proper}.
This is immediately clear if $I$ is finite, because the functions $t \mapsto \chi_i(t)$ are locally constant. If $I$ is infinite, then we write $$ I = \bigcup\nolimits_{I' \subset I\text{ finite}} I' $$ and we denote $P' = P|_{I'}$. Then we have $$ \Cohstack^P_{X/B} = \bigcap\nolimits_{I' \subset I\text{ finite}} \Cohstack^{P'}_{X/B} $$ Therefore, $\Cohstack^P_{X/B}$ is always an algebraic stack and the morphism $\Cohstack^P_{X/B} \subset \Cohstack_{X/B}$ is always a flat closed immersion, but it may no longer be an open substack. (We leave it to the reader to make examples). However, if $B$ is locally Noetherian, then so is $\Cohstack_{X/B}$ by Lemma \ref{lemma-coherent-qs-lfp} and Morphisms of Stacks, Lemma \ref{stacks-morphisms-lemma-locally-finite-type-locally-noetherian}. Hence if $U \to \Cohstack_{X/B}$ is a smooth surjective morphism where $U$ is a locally Noetherian scheme, then the inverse images of the open and closed substacks $\Cohstack^{P'}_{X/B}$ have an open intersection in $U$ (because connected components of locally Noetherian topological spaces are open). Thus the result in this case.
We may work \'etale locally on $B$, hence we may assume that $B$ is affine. In this case we may perform absolute Noetherian reduction; we suggest the reader skip the proof. Namely, say $B = \Spec(\Lambda)$. Write $\Lambda = \colim \Lambda_i$ as a filtered colimit with each $\Lambda_i$ of finite type over $\mathbf{Z}$. For some $i$ we can find a morphism of algebraic spaces $X_i \to \Spec(\Lambda_i)$ which is separated and of finite presentation and whose base change to $\Lambda$ is $X$. See Limits of Spaces, Lemmas \ref{spaces-limits-lemma-descend-finite-presentation} and \ref{spaces-limits-lemma-descend-separated-morphism}. Then after increasing $i$ we may assume there exist perfect objects $E_{1, i}, \ldots, E_{r, i}$ in $D(\mathcal{O}_{X_i})$ whose derived pullback to $X$ are isomorphic to $E_1, \ldots, E_r$, see Derived Categories of Spaces, Lemma \ref{spaces-perfect-lemma-perfect-on-limit}. Clearly we have a cartesian square $$ \xymatrix{ \Cohstack^P_{X/B} \ar[r] \ar[d] & \Cohstack_{X/B} \ar[d] \\ \Cohstack^P_{X_i/\Spec(\Lambda_i)} \ar[r] & \Cohstack_{X_i/\Spec(\Lambda_i)} } $$ and hence we may appeal to Lemma \ref{lemma-open-P} to finish the proof.
Suppose we have a scheme $T/B$ and two quotients $\mathcal{F}_T \to \mathcal{Q}_i$, $i = 1, 2$ corresponding to $T$-valued points of $\Quotfunctor_{\mathcal{F}/X/B}$ over $B$. Denote $\mathcal{K}_1$ the kernel of the first one and set $u : \mathcal{K}_1 \to \mathcal{Q}_2$ the composition. By Flatness on Spaces, Lemma \ref{spaces-flat-lemma-F-zero-closed-proper} there is a closed subspace of $T$ such that $T' \to T$ factors through it if and only if the pullback $u_{T'}$ is zero. This proves the diagonal is a closed immersion. Moreover, if $\mathcal{F}$ is of finite type, then $\mathcal{K}_1$ is of finite type (Modules on Sites, Lemma \ref{sites-modules-lemma-kernel-surjection-finite-onto-finite-presentation}) and we see that the diagonal is of finite presentation by the same lemma.
Taking base change, this immediately reduces to the following problem: given a valuation ring $R$ with fraction field $K$, an algebraic space $X$ proper over $R$, a finite type quasi-coherent $\mathcal{O}_X$-module $\mathcal{F}$, and a coherent quotient $\mathcal{F}_K \to \mathcal{Q}_K$, show there exists a quotient $\mathcal{F} \to \mathcal{Q}$ where $\mathcal{Q}$ is a finitely presented $\mathcal{O}_X$-module flat over $R$ whose generic fibre is $\mathcal{Q}_K$. Observe that by Flatness on Spaces, Theorem \ref{spaces-flat-theorem-finite-type-flat} any finite type quasi-coherent $\mathcal{O}_X$-module $\mathcal{F}$ flat over $R$ is of finite presentation. We first solve the existence of $\mathcal{Q}$ affine locally. \medskip\noindent Affine locally we arrive at the following problem: let $R \to A$ be a finitely presented ring map, let $M$ be a finite $A$-module, let $\varphi : M_K \to N_K$ be an $A_K$-quotient module. Then we may consider $$ L = \{x \in M \mid \varphi(x \otimes 1) = 0 \} $$ The $M \to M/L$ is an $A$-module quotient which is torsion free as an $R$-module. Hence it is flat as an $R$-module (More on Algebra, Lemma \ref{more-algebra-lemma-valuation-ring-torsion-free-flat}). Since $M$ is finite as an $A$-module so is $L$ and we conclude that $L$ is of finite presentation as an $A$-module (by the reference above). Clearly $M/L$ is the unqiue such quotient with $(M/L)_K = N_K$. \medskip\noindent The uniqueness in the construction of the previous paragraph guarantees these quotients glue and give the desired $\mathcal{Q}$. Here is a bit more detail. Choose a surjective \'etale morphism $U \to X$ where $U$ is an affine scheme. Use the above construction to construct a quotient $\mathcal{F}|_U \to \mathcal{Q}_U$ which is quasi-coherent, is flat over $R$, and recovers $\mathcal{Q}_K|U$ on the generic fibre. Since $X$ is separated, we see that $U \times_X U$ is an affine scheme \'etale over $X$ as well. Then $\mathcal{F}|_{U \times_X U} \to \text{pr}_1^*\mathcal{Q}_U$ and $\mathcal{F}|_{U \times_X U} \to \text{pr}_2^*\mathcal{Q}_U$ agree as quotients by the uniquess in the construction. Hence we may descend $\mathcal{F}|_U \to \mathcal{Q}_U$ to a surjection $\mathcal{F} \to \mathcal{Q}$ as desired (Properties of Spaces, Proposition \ref{spaces-properties-proposition-quasi-coherent}).
Set $\mathcal{G} = \pi_*\mathcal{F}$. Since $\pi$ is affine we see that for any scheme $T$ over $B$ we have $\mathcal{G}_T = \pi_{T, *}\mathcal{F}_T$ by Cohomology of Spaces, Lemma \ref{spaces-cohomology-lemma-affine-base-change}. Moreover $\pi_T$ is affine, hence $\pi_{T, *}$ is exact and transforms quotients into quotients. Observe that a quasi-coherent quotient $\mathcal{F}_T \to \mathcal{Q}$ defines a point of $\Quotfunctor_{X/B}$ if and only if $\mathcal{Q}$ defines an object of $\Cohstack_{X/B}$ over $T$ (similarly for $\mathcal{G}$ and $Y$). Since we've seen in Lemma \ref{lemma-coherent-functorial} that $\pi_*$ induces a morphism $\Cohstack_{X/B} \to \Cohstack_{Y/B}$ we see that if $\mathcal{F}_T \to \mathcal{Q}$ is in $\Quotfunctor_{\mathcal{F}/X/B}(T)$, then $\mathcal{G}_T \to \pi_{T, *}\mathcal{Q}$ is in $\Quotfunctor_{\mathcal{G}/Y/B}(T)$.
If $\mathcal{F}_T \to \mathcal{Q}$ is an element of $\Quotfunctor_{\mathcal{F}/X/B}(T)$ then we can consider $\mathcal{G}_T \to j_{T, *}\mathcal{F}_T \to j_{T, *}\mathcal{Q}$. Looking at stalks one finds that this is surjective. By Lemma \ref{lemma-coherent-functorial} we see that $j_{T, *}\mathcal{Q}$ is finitely presented, flat over $B$ with support proper over $B$. Thus we obtain a $T$-valued point of $\Quotfunctor_{\mathcal{G}/Y/B}$. This defines the morphism of the lemma. We omit the proof that this is an open immersion. Hint: If $\mathcal{G}_T \to \mathcal{Q}$ is an element of $\Quotfunctor_{\mathcal{G}/Y/B}(T)$ and for $t \in T$ we have $\text{Supp}(\mathcal{Q}_t) \subset |X_t|$, then the same is true for $t' \in T$ in a neighbourhood of $t$.
For every scheme $T$ over $B$ the morphism $\pi_T : X_T \to Y_T$ is a closed immersion. Then $\pi_{T, *}$ is an equivalence of categories between $\QCoh(\mathcal{O}_{X_T})$ and the full subcategory of $\QCoh(\mathcal{O}_{Y_T})$ whose objects are those quasi-coherent modules annihilated by the ideal sheaf of $X_T$, see Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-i-star-equivalence}. Since a qotient of $(\pi_*\mathcal{F})_T$ is annihilated by this ideal we obtain the bijectivity of the map $\Quotfunctor_{\mathcal{F}/X/B}(T) \to \Quotfunctor_{\pi_*\mathcal{F}/Y/B}(T)$ for all $T$ as desired.
Let $\mathcal{K} = \Ker(\mathcal{F} \to \mathcal{G})$. By right exactness of pullbacks we find that $\mathcal{K}_T \to \mathcal{F}_T \to \mathcal{G}_T \to 0$ is an exact sequecnce for all schemes $T$ over $B$. In particular, a quotient of $\mathcal{G}_T$ determines a quotient of $\mathcal{F}_T$ and we obtain our transformation of functors $\Quotfunctor_{\mathcal{G}/X/B} \to \Quotfunctor_{\mathcal{F}/X/B}$. This transformation is a closed immersion by Flatness on Spaces, Lemma \ref{spaces-flat-lemma-F-zero-closed-proper}. Namely, given an element $\mathcal{F}_T \to \mathcal{Q}$ of $\Quotfunctor_{\mathcal{F}/X/B}(T)$, then we see that the pull back to $T'/T$ is in the image of the transformation if and only if $\mathcal{K}_{T'} \to \mathcal{Q}_{T'}$ is zero.
The question is \'etale local over $B$, see Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-proper-local}. Thus we may assume $B$ is an affine scheme. In this case $\mathcal{L}$ is an ample invertible module on $X$ (by Constructions, Lemma \ref{constructions-lemma-ample-on-proj} and the definition of ample invertible modules in Properties, Definition \ref{properties-definition-ample}). Thus we can find $r' \geq 0$ and $r \geq 0$ and a surjection $$ \mathcal{O}_X^{\oplus r} \longrightarrow \mathcal{F} \otimes_{\mathcal{O}_X} \mathcal{L}^{\otimes r'} $$ by Properties, Proposition \ref{properties-proposition-characterize-ample}. By Lemma \ref{lemma-quot-tensor-invertible} we may replace $\mathcal{F}$ by $\mathcal{F} \otimes_{\mathcal{O}_X} \mathcal{L}^{\otimes r'}$ and $P(t)$ by $P(t + r')$. By Lemma \ref{lemma-quot-quotient} we obtain a closed immersion $$ \Quotfunctor^P_{\mathcal{F}/X/B} \longrightarrow \Quotfunctor^P_{\mathcal{O}_X^{\oplus r}/X/B} $$ Since we've shown that $\Quotfunctor^P_{\mathcal{O}_X^{\oplus r}/X/B} \to B$ is proper in Lemma \ref{lemma-quot-Pn} we conclude.
The question is \'etale local over $B$, see Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-proper-local}. Thus we may assume $B$ is an affine scheme. Then we can find a closed immersion $i : X \to \mathbf{P}^n_B$ such that $i^*\mathcal{O}_{\mathbf{P}^n_B}(1) \cong \mathcal{L}^{\otimes d}$ for some $d \geq 1$. See Morphisms, Lemma \ref{morphisms-lemma-quasi-projective-finite-type-over-S}. Changing $\mathcal{L}$ into $\mathcal{L}^{\otimes d}$ and the numerical polynomial $P(t)$ into $P(dt)$ leaves $\Quotfunctor^P_{\mathcal{F}/X/B}$ unaffected; some details omitted. Hence we may assume $\mathcal{L} = i^*\mathcal{O}_{\mathbf{P}^n_B}(1)$. Then the isomorphism $\Quotfunctor_{\mathcal{F}/X/B} \to \Quotfunctor_{i_*\mathcal{F}/\mathbf{P}^n_B/B}$ of Lemma \ref{lemma-quot-closed} induces an isomorphism $\Quotfunctor^P_{\mathcal{F}/X/B} \cong \Quotfunctor^P_{i_*\mathcal{F}/\mathbf{P}^n_B/B}$. Since $\Quotfunctor^P_{i_*\mathcal{F}/\mathbf{P}^n_B/B}$ is proper over $B$ by Lemma \ref{lemma-quot-Pn-over-base} we conclude.
We have already seen that $\Quotfunctor_{\mathcal{F}/X/B} \to B$ is separated and locally of finite presentation, see Lemma \ref{lemma-quot-s-lfp}. Thus it suffices to show that the open subspace $\Quotfunctor^P_{\mathcal{F}/X/B}$ of Remark \ref{remark-quot-numerical} is quasi-compact over $B$. \medskip\noindent The question is \'etale local on $B$ (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-quasi-compact-local}). Thus we may assume $B$ is affine. \medskip\noindent Assume $B = \Spec(\Lambda)$. Write $\Lambda = \colim \Lambda_i$ as the colimit of its finite type $\mathbf{Z}$-subalgebras. Then we can find an $i$ and a system $X_i, \mathcal{F}_i, \mathcal{L}_i$ as in the lemma over $B_i = \Spec(\Lambda_i)$ whose base change to $B$ gives $X, \mathcal{F}, \mathcal{L}$. This follows from Limits of Spaces, Lemmas \ref{spaces-limits-lemma-descend-finite-presentation} (to find $X_i$), \ref{spaces-limits-lemma-descend-modules-finite-presentation} (to find $\mathcal{F}_i$), \ref{spaces-limits-lemma-descend-invertible-modules} (to find $\mathcal{L}_i$), and \ref{spaces-limits-lemma-descend-separated} (to make $X_i$ separated). Because $$ \Quotfunctor_{\mathcal{F}/X/B} = B \times_{B_i} \Quotfunctor_{\mathcal{F}_i/X_i/B_i} $$ and similarly for $\Quotfunctor^P_{\mathcal{F}/X/B}$ we reduce to the case discussed in the next paragraph. \medskip\noindent Assume $B$ is affine and Noetherian. We may replace $\mathcal{L}$ by a positive power, see Lemma \ref{lemma-quot-power-invertible}. Thus we may assume there exists an immersion $i : X \to \mathbf{P}^n_B$ such that $i^*\mathcal{O}_{\mathbf{P}^n}(1) = \mathcal{L}$. By Morphisms, Lemma \ref{morphisms-lemma-quasi-compact-immersion} there exists a closed subscheme $X' \subset \mathbf{P}^n_B$ such that $i$ factors through an open immersion $j : X \to X'$. By Properties, Lemma \ref{properties-lemma-lift-finite-presentation} there exists a finitely presented $\mathcal{O}_{X'}$-module $\mathcal{G}$ such that $j^*\mathcal{G} = \mathcal{F}$. Thus we obtain an open immersion $$ \Quotfunctor_{\mathcal{F}/X/B} \longrightarrow \Quotfunctor_{\mathcal{G}/X'/B} $$ by Lemma \ref{lemma-quot-better-open}. Clearly this open immersion sends $\Quotfunctor^P_{\mathcal{F}/X/B}$ into $\Quotfunctor^P_{\mathcal{G}/X'/B}$. Now $\Quotfunctor^P_{\mathcal{G}/X'/B}$ is proper over $B$ by Lemma \ref{lemma-quot-proper-over-base}. Therefore it is Noetherian and since any open of a Noetherian algebraic space is quasi-compact we win.
Since $\pi$ is a closed immersion, it is immediate that given a closed subscheme $Z \subset X_T$, we can view $Z$ as a closed subscheme of $X_T$. Thus we obtain the transformation $\Hilbfunctor_{X/B} \to \Hilbfunctor_{Y/B}$. This transformation is immediately seen to be a monomorphism. To prove that it is a closed immersion, you can use Lemma \ref{lemma-quot-quotient} for the map $\mathcal{O}_Y \to \mathcal{O}_X$ and the identifications $\Hilbfunctor_{X/B} = \Quotfunctor_{\mathcal{O}_X/X/B}$, $\Hilbfunctor_{Y/B} = \Quotfunctor_{\mathcal{O}_Y/Y/B}$ of Quot, Lemma \ref{quot-lemma-hilb-is-quot}.
Taking base change, this immediately reduces to the following problem: given a valuation ring $R$ with fraction field $K$ and an algebraic space $X$ proper and smooth over $R$ and an invertible $\mathcal{O}_{X_K}$-module $\mathcal{L}_K$, show there exists an invertible $\mathcal{O}_X$-module $\mathcal{L}$ whose generic fibre is $\mathcal{L}_K$. Observe that $X_K$ is Noetherian, separated, and regular (use Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-finite-presentation-noetherian} and Spaces over Fields, Lemma \ref{spaces-over-fields-lemma-smooth-regular}). Thus we can write $\mathcal{L}_K$ as the difference in the Picard group of $\mathcal{O}_{X_K}(D_K)$ and $\mathcal{O}_{X_K}(D'_K)$ for two effective Cartier divisors $D_K, D'_K$ in $X_K$, see Divisors on Spaces, Lemma \ref{spaces-divisors-lemma-Noetherian-regular-separated-pic-effective-Cartier}. Finally, we know that $D_K$ and $D'_K$ are restrictions of effective Cartier divisors $D, D' \subset X$, see Divisors on Spaces, Lemma \ref{spaces-divisors-lemma-smooth-over-valuation-ring-effective-Cartier}.
We already know that $\Picardstack_{X/B} \to B$ is locally of finite presentation, see Lemma \ref{lemma-pic-qs-lfp}. Thus it suffices to show that $\Picardstack_{X/B} \to B$ is formally smooth, see More on Morphisms of Stacks, Lemma \ref{stacks-more-morphisms-lemma-smooth-formally-smooth}. Taking base change, this immediately reduces to the following problem: given a first order thickening $T \subset T'$ of affine schemes, given $X' \to T'$ proper, flat, of finite presentation and of relative dimension $\leq 1$, and for $X = T \times_{T'} X'$ given an invertible $\mathcal{O}_X$-module $\mathcal{L}$, prove that there exists an invertible $\mathcal{O}_{X'}$-module $\mathcal{L}'$ whose restriction to $X$ is $\mathcal{L}$. Since $T \subset T'$ is a first order thickening, the same is true for $X \subset X'$, see More on Morphisms of Spaces, Lemma \ref{spaces-more-morphisms-lemma-base-change-thickening}. By More on Morphisms of Spaces, Lemma \ref{spaces-more-morphisms-lemma-picard-group-first-order-thickening} we see that it suffices to show $H^2(X, \mathcal{I}) = 0$ where $\mathcal{I}$ is the quasi-coherent ideal cutting out $X$ in $X'$. Denote $f : X \to T$ the structure morphism. By Cohomology of Spaces, Lemma \ref{spaces-cohomology-lemma-higher-direct-images-zero-above-dimension-fibre} we see that $R^pf_*\mathcal{I} = 0$ for $p > 1$. Hence we get the desired vanishing by Cohomology of Spaces, Lemma \ref{spaces-cohomology-lemma-quasi-coherence-higher-direct-images-application} (here we finally use that $T$ is affine).
The definition of $\Picardstack_{X/B} \to \Picardfunctor_{X/B}$ being a gerbe is given in Morphisms of Stacks, Definition \ref{stacks-morphisms-definition-gerbe}, which in turn refers to Stacks, Definition \ref{stacks-definition-gerbe-over-stack-in-groupoids}. To prove it, we will check conditions (2)(a) and (2)(b) of Stacks, Lemma \ref{stacks-lemma-when-gerbe}. This follows immediately from Quot, Lemma \ref{quot-lemma-pic-over-pic}; here is a detailed explanation. \medskip\noindent Condition (2)(a). Suppose that $\xi \in \Picardfunctor_{X/B}(U)$ for some scheme $U$ over $B$. Since $\Picardfunctor_{X/B}$ is the fppf sheafification of the rule $T \mapsto \Pic(X_T)$ on schemes over $B$ (Quot, Situation \ref{quot-situation-pic}), we see that there exists an fppf covering $\{U_i \to U\}$ such that $\xi|_{U_i}$ corresponds to some invertible module $\mathcal{L}_i$ on $X_{U_i}$. Then $(U_i \to B, \mathcal{L}_i)$ is an object of $\Picardstack_{X/B}$ over $U_i$ mapping to $\xi|_{U_i}$. \medskip\noindent Condition (2)(b). Suppose that $U$ is a scheme over $B$ and $\mathcal{L}, \mathcal{N}$ are invertible modules on $X_U$ which map to the same element of $\Picardfunctor_{X/B}(U)$. Then there exists an fppf covering $\{U_i \to U\}$ such that $\mathcal{L}|_{X_{U_i}}$ is isomorphic to $\mathcal{N}|_{X_{U_i}}$. Thus we find isomorphisms between $(U \to B, \mathcal{L})|_{U_i} \to (U \to B, \mathcal{N})|_{U_i}$ as desired.
The diagonal is an immersion by Quot, Lemma \ref{quot-lemma-diagonal-pic}. To finish we show that the diagonal is quasi-compact. The diagonal of $\Picardstack_{X/B}$ is quasi-compact by Lemma \ref{lemma-pic-diagonal-affine-fp} and $\Picardstack_{X/B}$ is a gerbe over $\Picardfunctor_{X/B}$ by Lemma \ref{lemma-pic-gerbe-over-pic-functor}. We conclude by Morphisms of Stacks, Lemma \ref{stacks-morphisms-lemma-gerbe-diagonal-quasi-compact}.