The invention relates to the technical field of
artificial intelligence and natural languages, in particular to a long document question and answer generation method based on a large
language model.The method comprises the steps that approximate
nearest neighbor search is conducted through an HNSW index, N most relevant triads are retrieved, and for each position in the retrieved triads, a fixed-size window such as [-M, M] is obtained; all (k, v) pairs within a range of 1, 2, 3, 4, 5, 6, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, a new K'matrix and a new V 'matrix are formed by splicing (k, v) pairs obtained by retrieval and expansion with K and V matrixes of a current input sequence, attention is calculated by using a standard
zoom dot product attention mechanism, and only vectors corresponding to an input problem sequence are reserved, so that the global view is ensured, unnecessary calculation is avoided, and the accuracy of the attention calculation is improved. Therefore, the serious problems of calculation efficiency and memory use during long
sequence processing are solved.