Resources/Model training/Training methods

Method

Learning from documents: Q&A generation

Q&A generation turns documents into training examples: a model reads each section of your text and writes realistic questions, with answers taken only from that section. The pairs then train like any other chat, on every provider.

Chapter 75 min read5 references

What it is

A model fine-tuned on a few dozen chats usually learns the tone and the format quickly. What it doesn't learn is the facts it never saw: which plans include exports, how long a shared link lasts, what a setting is called. Evaluations show this clearly: such a model scores well on tone and format and poorly on correctness. The facts usually live in documents: help articles, manuals, product pages.

Q&A generation rewrites those documents into the shape supervised training understands. A model reads each section of the text and writes a few question-and-answer pairs about it. Those pairs join your dataset as ordinary examples, so the facts reach the model through the same prep, training and evaluation as your chats.

Why not just train on the text itself? Research suggests models learn facts poorly from a single copy. Ovadia et al. (2023) found that models “struggle to learn new factual information through unsupervised fine-tuning” and that seeing many variations of the same fact helps. Yang et al. (2024) note that a model must see a fact in “hundreds to thousands of diverse representations” to learn it during pre-training. Questions written in different words are exactly such variations, and they also teach the model to retrieve the fact when asked.

Getting documents into a dataset

  • Upload files: PDF, Word, PowerPoint, text, Markdown or HTML.
  • Pick files already in Scalata; their extracted text is reused.
  • Paste web page addresses. Only public pages: the main text is kept and menus and footers are dropped. Addresses that point inside your network are refused.
  • Import a Hugging Face dataset's plain-text rows (web pages, books…). Rows are joined into documents of up to 40,000 characters.
  • Pick files from a connected data source such as Google Drive, OneDrive, Amazon S3 or Snowflake. Only readable documents are listed, files over 50 MB can't be picked, and the source is only read, never changed.

Each document's text is read once and can be checked with View text before it's used. That check is worth a minute: a scanned PDF with poor text, or a page that is mostly navigation, gives poor questions.

How it works

  1. Cut into sections. The text is split into sections of about 900 words. Neighbouring sections overlap a little, so a fact that falls on a boundary appears whole in at least one of them.
  2. Read one section at a time. The generator model you pick reads a section and writes a few realistic question-and-answer pairs.
  3. Questions like users. They are phrased the way people actually type (“how do i share this”), not like exam questions.
  4. Answers only from the section. The generator may use no facts that aren't in the text in front of it. A section with nothing to ask about, such as a list of references, gives no questions.
  5. Your tone. If the dataset already has chats, a few real replies are shown to the generator so the answers sound like your product.
  6. Ordinary examples. The pairs land in the dataset, where you can review, edit or delete them before prep.
HELP ARTICLE · 2,500 WORDSsection 1section 2section 3overlapoverlap
from section 1how do i share a report with a client?Open the report → Share → pick the client.
from section 2does the client need an account to open it?No. The link opens without one and expires after 7 days.
from section 3can i stop sharing laterYes. Share → Manage links → Revoke.
One article becomes training examples. The text is cut into sections of about 900 words; neighbouring sections share a little text (shaded), so a fact on a boundary is seen whole. A model reads each section and writes questions the way users type them, with answers drawn only from that section. Article and pairs are illustrative.
One generated pair, as a training example
{"messages": [
  {"role": "user",      "content": "does the client need an account to open a shared report?"},
  {"role": "assistant", "content": "No. The link opens without an account and expires after 7 days. You can revoke it any time under Share → Manage links."}
]}
One help article, end to end (illustrative)
  1. A 2,500-word article on sharing reports goes into the dataset. View text shows clean paragraphs, so it is ready.
  2. It is cut into three sections: words 1–900, 800–1,700 and 1,600–2,500. The sentence about links expiring after 7 days sits at word 850, so it appears whole in both section 1 and section 2.
  3. The generator writes three pairs per section: nine examples. One question is “does the client need an account to open it?”, answered from section 2 only.
  4. You review all nine and fix one answer that blurred two settings together. Review a sample on every run: a generated answer is only as good as the section it came from.
  5. The nine examples train with your chats. The evaluation's correctness scores on sharing questions are what tell you it worked.

Getting good pairs

  • Use current documents only. Pairs from an outdated manual teach outdated facts, confidently.
  • Prefer clean text. Help articles and product pages work best; pages of tables, references or navigation give little.
  • Mix with real chats. Generated pairs carry the facts; real chats carry the multi-turn behaviour and edge cases users actually bring.
  • Don't overload the model with new facts. Gekhman et al. (2024) found that fine-tuning examples with knowledge new to the model are learned more slowly and, once learned, make it more prone to hallucinate. Keep answers grounded, and consider retrieval for facts that change often.

Q&A generation or continued pre-training?

CompareGenerated Q&AContinued pre-training
ProvidersEvery providerHugging Face; Vertex AI open models
Text neededWorks from a few pagesTens of thousands of words or more
TeachesFacts, in the form of answersKnowledge only; answering needs a supervised run after
Can you review it?Yes, every pairOnly the source text

Choose generated Q&A when you want better answers soon and on any provider. Choose continued pre-training when you have a large body of documentation and train open models, ideally followed by generated Q&A or chat training that continues from it.

Settings

Section sizeTypical About 900 words, slightly overlapping#

How much text the generator reads at once. About 900 words, with a little overlap between neighbouring sections so a fact on a boundary is seen whole. Larger sections give the generator more context but tend to produce questions about only the most prominent facts; smaller ones cover details more evenly but lose the surrounding context.

Generator modelTypical A fast, affordable model that follows instructions well#

The model that reads each section and writes the pairs. A capable model follows the “answer only from the section” rule more reliably and writes more natural questions. Generation is a one-off cost per document and is usually small next to training; the estimate is shown before you start.

Common mistakes

  • Skipping the review. A generated answer is only as accurate as its section, and the generator can still blur two facts together.
  • Feeding in outdated or draft documents. The model learns whatever the text says.
  • Training on generated pairs alone. Without real chats the model may answer facts well but handle real conversations poorly.
  • Not checking View text on scanned or heavily formatted files, where the extracted text may be garbled.
  • Judging the result on tone. Q&A generation targets correctness, so read the evaluation's correctness scores.

References and further reading

External sources open in a new tab.

  1. 01Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMsOvadia et al., 2023 · arXiv · arxiv.orgModels learn new facts poorly from raw text; many variations of a fact help.
  2. 02Synthetic continued pretrainingYang et al., 2024 · arXiv · arxiv.orgRewriting a small corpus into much more varied synthetic text so a model can learn from it.
  3. 03Physics of Language Models: Part 3.1, Knowledge Storage and ExtractionAllen-Zhu & Li, 2023 · arXiv · arxiv.orgControlled experiments showing knowledge must be seen in varied forms to be retrievable by questions.
  4. 04Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?Gekhman et al., 2024 · arXiv · arxiv.orgWhy teaching many new facts through fine-tuning can increase hallucination.
  5. 05Instruction Pre-Training: Language Models are Supervised Multitask LearnersCheng et al., 2024 · arXiv · arxiv.orgAugmenting raw text with generated instruction–response pairs during continued pre-training.

Turn weeks of expert work into minutes

See how Scalata fits your team, your data, and your controls.