Let $y : \Spec(k) \to Y$ be a field valued point. Then the fibre $X_y$ of $f$ at $y$ is connected by our assumption that $H^0(X_y, \mathcal{O}_{X_y}) = k$. Thus the rank of $\mathcal{E}$ is constant on the fibres. Since $f$ is open (Morphisms of Spaces, Lemma \ref{spaces-morphisms-lemma-fppf-open}) and closed we conclude that there is a decomposition $Y = \coprod Y_r$ of $Y$ into open and closed subspaces such that $\mathcal{E}$ has constant rank $r$ on the inverse image of $Y_r$. Thus we may assume $\mathcal{E}$ has constant rank $r$. We will denote $\mathcal{E}^\vee = \SheafHom(\mathcal{E}, \mathcal{O}_X)$ the dual rank $r$ module. \medskip\noindent By cohomology and base change (more precisely by Derived Categories of Spaces, Lemma \ref{spaces-perfect-lemma-flat-proper-perfect-direct-image-general}) we see that $E = Rf_*\mathcal{E}$ is a perfect object of the derived category of $Y$ and that its formation commutes with arbitrary change of base. Similarly for $E' = Rf_*\mathcal{E}^\vee$. Since there is never any cohomology in degrees $< 0$, we see that $E$ and $E'$ have (locally) tor-amplitude in $[0, b]$ for some $b$. Observe that for any $g : Y' \to Y$ we have $f'_*((g')^*\mathcal{E}) = H^0(Lg^*E)$ and $f'_*((g')^*\mathcal{E}^\vee) = H^0(Lg^*E')$. Let $j : Z \to Y$ and $j' : Z' \to Y$ be the locally closed immersions constructed in Derived Categories of Spaces, Lemma \ref{spaces-perfect-lemma-locally-closed-where-H0-locally-free} for $E$ and $E'$ with $a = 0$ and $r = r$; these are characterized by the property that $H^0(Lj^*E)$ and $H^0((j')^*E')$ are locally free modules of rank $r$ compatible with pullback. \medskip\noindent Let $g : Y' \to Y$ be a morphism. If there exists an $\mathcal{N}$ as in the lemma, then, using the projection formula Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-projection-formula}, we see that the modules $$ f'_*((g')^*\mathcal{E}) \cong f'_*((f')^*\mathcal{N}) \cong \mathcal{N} \otimes_{\mathcal{O}_{Y'}} f'_*\mathcal{O}_{X'} \cong \mathcal{N}\quad\text{and similarly }\quad f'_*((g')^*\mathcal{E}^\vee) \cong \mathcal{N}^\vee $$ are locally free of rank $r$ and remain locally free of rank $r$ after any further base change $Y'' \to Y'$. Hence in this case $g : Y' \to Y$ factors through $j$ and through $j'$. Thus we may replace $Y$ by $Z \times_Y Z'$ and assume that $f_*\mathcal{E}$ and $f_*\mathcal{E}^\vee$ are locally free $\mathcal{O}_Y$-modules of rank $r$ whose formation commutes with arbitrary change of base. \medskip\noindent In this sitation if $g : Y' \to Y$ is a morphism and there exists an $\mathcal{N}$ as in the lemma, then the map (cup product in degree $0$) $$ f'_*((g')^*\mathcal{E}) \otimes_{\mathcal{O}_{Y'}} f'_*((g')^*\mathcal{E}^\vee) \longrightarrow \mathcal{O}_{Y'} $$ is a perfect pairing. Conversely, if this cup product map is a perfect pairing, then we see that locally on $Y'$ we have a basis of sections $\sigma_1, \ldots, \sigma_r$ in $f'_*((g')^*\mathcal{L})$ and $\tau_1, \ldots, \tau_r$ in $f'_*((g')^*\mathcal{E}^\vee)$ whose products satisfy $\sigma_i \tau_j = \delta_{ij}$. Thinking of $\sigma_i$ as a section of $(g')^*\mathcal{L}$ on $X'$ and $\tau_j$ as a section of $(g')^*\mathcal{L}^\vee$ on $X'$, we conclude that $$ \sigma_1, \ldots, \sigma_r : \mathcal{O}_{X'}^{\oplus r} \longrightarrow (g')^*\mathcal{E} $$ is an isomorphism with inverse given by $$ \tau_1, \ldots, \tau_r : (g')^*\mathcal{E} \longrightarrow \mathcal{O}_{X'}^{\oplus r} $$ In other words, we see that $(f')^*f'_*(g')^*\mathcal{E} \cong (g')^*\mathcal{E}$. But the condition that the cupproduct is nondegenerate picks out a retrocompact open subscheme (namely, the locus where a suitable determinant is nonzero) and the proof is complete.