<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Blog · DAH Labs</title>
  <subtitle>What the community learns, builds and shares — written by and for data &amp; AI practitioners.</subtitle>
  <link href="https://dah-projects-and-innovations.github.io/dah-labs-site/en/feed.xml" rel="self"/>
  <link href="https://dah-projects-and-innovations.github.io/dah-labs-site/en/blog/"/>
  <id>https://dah-projects-and-innovations.github.io/dah-labs-site/en/blog/</id>
  <icon>https://dah-projects-and-innovations.github.io/dah-labs-site/favicon-32.png</icon>
  <updated>2026-10-12T00:00:00.000Z</updated>
  <entry xml:lang="en">
    <title>TranslatePsy-AfriSLM tested in Wolof and Yoruba: when a small model beats a big one</title>
    <link href="https://dah-projects-and-innovations.github.io/dah-labs-site/en/blog/translatepsy-afrislm/"/>
    <id>https://dah-projects-and-innovations.github.io/dah-labs-site/en/blog/translatepsy-afrislm/</id>
    <published>2026-10-12T00:00:00.000Z</published>
    <updated>2026-10-12T00:00:00.000Z</updated>
    <author><name>Outreach &amp; Tech Watch team</name></author>
    <category term="africa" label="Data &amp; Africa"/>
    <summary>A 0.8-billion-parameter translation model outperforms systems 30 to 150 times larger across 19 African languages. We tested it in Wolof and Yoruba, with native speakers.</summary>
    <content type="html">&lt;p&gt;AI assistants handle English and French well, but what about African languages such as Yoruba, Hausa or Wolof? A research team recently showed that a tiny model can outperform much larger systems on these low-resource languages. We wanted to check for ourselves.&lt;/p&gt;
&lt;h2 id=&quot;what-the-paper-proposes&quot;&gt;What the paper proposes&lt;/h2&gt;
&lt;p&gt;The Tether AI Research team (Milan Gritta, Patrik Lambert, Jihye Back and Amril Nazir) published &lt;strong&gt;TranslatePsy-AfriSLM&lt;/strong&gt; on arXiv: a set of open machine translation resources for &lt;strong&gt;19 Sub-Saharan African languages&lt;/strong&gt;, including Wolof, Yoruba, Hausa, Igbo, Swahili and Amharic. The project includes filtered parallel data, synthetic data and three small models (0.8, 2 and 4 billion parameters), all available on Hugging Face.&lt;/p&gt;
&lt;p&gt;The headline result: the smallest model, with 0.8 billion parameters, beats much larger models on all three benchmarks tested (Flores-200, BOUQuET and Smol), including &lt;strong&gt;TranslateGemma-27B&lt;/strong&gt; and &lt;strong&gt;Qwen3.5-122B-A10B&lt;/strong&gt;, according to SSA-COMET, a metric designed to evaluate African languages.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://arxiv.org/html/2608.18655v2/figures/size_vs_performance_bouquet.png&quot; alt=&quot;Chart: SSA-COMET score by model size. The three TranslatePsy-AfriSLM models (0.8B, 2B and 4B) sit in the top left, above much larger models such as TranslateGemma-27B and Qwen3.5-122B.&quot;&gt;
&lt;em&gt;Fig. 1. Translation quality (SSA-COMET, BOUQuET benchmark) by model size: the TranslatePsy-AfriSLM models (green dots) outperform models up to 150 times larger. Source: Gritta et al. (2026), Figure 1, CC BY 4.0 licence.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;data-quality-before-model-size&quot;&gt;Data quality before model size&lt;/h3&gt;
&lt;p&gt;How does such a small model do better? The authors credit &lt;strong&gt;the filtering of the training data&lt;/strong&gt;. Each sentence pair (a sentence and its translation) gets a quality score computed by three automatic evaluation tools, and only the best pairs are kept.&lt;/p&gt;
&lt;p&gt;The effect is striking: trained on all the raw open data (nearly 45 billion tokens), a model reaches the same score as one trained on just 1.76 billion well-chosen tokens. Filtering therefore removes &lt;strong&gt;up to 96% of the data with no loss in quality&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://arxiv.org/html/2608.18655v2/figures/pareto_frontier_ssa_vs_tokens__bouquet.png&quot; alt=&quot;Chart: SSA-COMET score by number of training tokens. The model trained on raw data, in the bottom right, uses nearly 45 billion tokens for a lower score than many far leaner filtered configurations.&quot;&gt;
&lt;em&gt;Fig. 2. Each shape is a model trained on a different data mix. The &amp;quot;Open-source (Unfiltered)&amp;quot; model, in the bottom right, uses the most data for one of the lowest scores. Source: Gritta et al. (2026), Figure 4, CC BY 4.0 licence.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;our-test&quot;&gt;Our test&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Model:&lt;/strong&gt; &lt;a href=&quot;https://huggingface.co/qvac/TranslatePsy-AfriSLM-0.8B&quot;&gt;qvac/TranslatePsy-AfriSLM-0.8B&lt;/a&gt;, the smallest of the three.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Languages:&lt;/strong&gt; Wolof and Yoruba.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Directions:&lt;/strong&gt; English ↔ Wolof and English ↔ Yoruba, both ways.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sentences:&lt;/strong&gt; 15 everyday sentences.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Evaluation:&lt;/strong&gt; each translation was reviewed by a Wolof or Yoruba speaker, who judged its quality and faithfulness to the original meaning.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We could not get the model running on our own computers: the test was run on Google Colab.&lt;/p&gt;
&lt;h2 id=&quot;results&quot;&gt;Results&lt;/h2&gt;
&lt;p&gt;Out of 15 sentences, &lt;strong&gt;14 were rated good&lt;/strong&gt; by our native reviewers, and only one average.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Direction&lt;/th&gt;
&lt;th&gt;Sentences&lt;/th&gt;
&lt;th&gt;Good&lt;/th&gt;
&lt;th&gt;Average&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Wolof → English&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;English → Wolof&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;English → Yoruba&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Yoruba → English&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;A few representative examples:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Source sentence&lt;/th&gt;
&lt;th&gt;Direction&lt;/th&gt;
&lt;th&gt;Translation&lt;/th&gt;
&lt;th&gt;Reviewer&#39;s verdict&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Senegal, dëkk bu am téranga la&lt;/td&gt;
&lt;td&gt;Wolof → English&lt;/td&gt;
&lt;td&gt;Senegal is a very teranga city.&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;I&#39;m heading to work, I&#39;ll be back late&lt;/td&gt;
&lt;td&gt;English → Wolof&lt;/td&gt;
&lt;td&gt;Maa ngi dem liggéey, dinaa dellu lu yàgg.&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Man ngi dem daara&lt;/td&gt;
&lt;td&gt;Wolof → English&lt;/td&gt;
&lt;td&gt;I&#39;m going to bed.&lt;/td&gt;
&lt;td&gt;Average: &amp;quot;daara&amp;quot; (Quranic school) is mistranslated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Could you please tell me how I can get to the train station from here?&lt;/td&gt;
&lt;td&gt;English → Yoruba&lt;/td&gt;
&lt;td&gt;Jọ̀wọ́ sọ fún mi bí mo ṣe lè dé ibùdókọ̀ ojú irin láti ibí yìí?&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mo sábà máa ń tètè jí láàárọ̀, mo sì máa ń mu ife kọfí kí n tó bẹ̀rẹ̀ ọjọ́ mi.&lt;/td&gt;
&lt;td&gt;Yoruba → English&lt;/td&gt;
&lt;td&gt;I usually wake up early in the morning and have a cup of coffee before I start my day&lt;/td&gt;
&lt;td&gt;Good, with a slight nuance&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The last row is a &lt;strong&gt;round trip&lt;/strong&gt;: the Yoruba sentence is the model&#39;s own translation of &amp;quot;I usually wake up early in the morning and start my day with a cup of coffee&amp;quot;. The meaning comes back almost intact. The only nuance: the coffee now comes &lt;em&gt;before&lt;/em&gt; the day starts, whereas the original sentence starts the day &lt;em&gt;with&lt;/em&gt; a coffee.&lt;/p&gt;
&lt;p&gt;Processing time ranged from 19 to 60 seconds per sentence on Colab, with one outlier at 120 seconds.&lt;/p&gt;
&lt;p&gt;These results are in line with the paper. On the BOUQuET benchmark, fine-tuning clearly improves both Wolof and Yoruba compared with the base model:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://arxiv.org/html/2608.18655v2/figures/africa_iid_bouquet_per_language.png&quot; alt=&quot;Four bar charts, one per metric (COMET-22, SSA-COMET, MetricX, chrF++), for 19 African languages, before (Qwen3.5-2B, grey) and after fine-tuning (TranslatePsy-AfriSLM-2B, green). On SSA-COMET, the score rises by 0.355 for Yoruba and 0.262 for Wolof.&quot;&gt;
&lt;em&gt;Fig. 3. Per-language scores on four metrics, before (grey) and after (green) fine-tuning, for the 2B model. In the second chart (SSA-COMET), Wolof (wol) and Yoruba (yor) go from about 0.3 to over 0.6. Source: Gritta et al. (2026), Figure 11, CC BY 4.0 licence.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The paper also shows that Wolof remains a hard language: on MetricX (third chart, where lower is better), it is the language where the 2B model scores worst of all 19.&lt;/p&gt;
&lt;h2 id=&quot;what-the-test-taught-us&quot;&gt;What the test taught us&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;The model only works from English.&lt;/strong&gt; We also tried translating from French into Wolof and Yoruba: the model returned the sentences unchanged. This is not surprising: it was trained on English ↔ African language pairs, and the authors do not test French as a source language.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Spelling matters.&lt;/strong&gt; The model is sensitive to spelling, accents and the characters specific to each language (ë, ñ, ŋ, à, é, ó, ọ, ṣ…). A sentence written in the standard orthography is understood far better than text typed on the fly. This kind of test therefore needs a skilled speaker, able to write correctly and to judge the result.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fifteen sentences are not a benchmark.&lt;/strong&gt; Our test is a first look, not a full evaluation: it tells us whether the model is usable on simple sentences, not how it handles long, technical or highly idiomatic text.&lt;/p&gt;
&lt;h2 id=&quot;why-it-matters-for-africa&quot;&gt;Why it matters for Africa&lt;/h2&gt;
&lt;p&gt;What makes this work interesting to us is not only performance: it is size. A 0.8-billion-parameter model costs far less to run than a 27- or 122-billion-parameter one, a gap that matters directly where connectivity is limited and every hour of compute is negotiated. It is not yet a model that runs offline on an entry-level phone (we did not even get it running on a laptop), but it points the way: proof that you can aim for frugality without sacrificing quality.&lt;/p&gt;
&lt;p&gt;The other contribution, less visible but just as important, is the dataset itself: 19 African languages, with open and documented resources. This is exactly the kind of building block a project like AfriVoice can build on, and a reminder that data quality often matters more than model size, a principle that applies to our own work too.&lt;/p&gt;
&lt;p&gt;Finally, the &amp;quot;daara&amp;quot; error is a useful reminder that a benchmark score does not tell the whole story. Only a review by a native speaker reveals this kind of cultural and linguistic nuance. The authors acknowledge this themselves: their paper closes on the need for human evaluation to measure the real quality of translations into African languages. That is exactly what our hands-on tech watch aims to do: test an impressive number against real use rather than simply passing it on.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key takeaway&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A 0.8-billion-parameter model, trained on carefully filtered data, translates Wolof and Yoruba better than models 30 to 150 times larger. Our test confirms it is usable on everyday sentences, as long as you start from English and write in the standard orthography.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Gritta, M., Lambert, P., Back, J., &amp;amp; Nazir, A. (2026). &lt;em&gt;TranslatePsy-AfriSLM: High-Quality Data Scaling For Low-Resource Machine Translation&lt;/em&gt;. Tether AI Research. &lt;a href=&quot;https://arxiv.org/abs/2608.18655&quot;&gt;arXiv:2608.18655&lt;/a&gt;, CC BY 4.0 licence.&lt;/li&gt;
&lt;li&gt;Models and data on Hugging Face: &lt;a href=&quot;https://huggingface.co/collections/qvac/translatepsy-afrislm&quot;&gt;qvac/translatepsy-afrislm collection&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</content>
  </entry>
  <entry xml:lang="en">
    <title>Build your first RAG assistant with LangChain</title>
    <link href="https://dah-projects-and-innovations.github.io/dah-labs-site/en/blog/rag-langchain/"/>
    <id>https://dah-projects-and-innovations.github.io/dah-labs-site/en/blog/rag-langchain/</id>
    <published>2026-09-28T00:00:00.000Z</published>
    <updated>2026-09-28T00:00:00.000Z</updated>
    <author><name>DAH Labs Team</name></author>
    <category term="tuto" label="Tutorial"/>
    <summary>From indexing documents to the first answer: the key steps to build an assistant grounded in your own data.</summary>
    <content type="html">&lt;p&gt;A language model only knows what it saw during training. It knows nothing about your internal reports, your datasets or your project documentation — and when asked about them, it may confidently make something up.&lt;/p&gt;
&lt;p&gt;Retrieval-Augmented Generation (RAG) fills that gap. Before answering, the assistant looks up the relevant passages in your own documents, then uses them as context to build its answer. This post walks through the four building blocks of a RAG pipeline and a first implementation in Python.&lt;/p&gt;
&lt;h2 id=&quot;why-rag&quot;&gt;Why RAG?&lt;/h2&gt;
&lt;p&gt;Retraining a model on your data is expensive and quickly goes stale. With RAG, your documents stay separate from the model: update them and the assistant takes the changes into account on the next question. Another benefit is traceability — every answer can point to the passages it was built from, which makes it verifiable.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key takeaway&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;RAG doesn&#39;t make the model smarter: it gives it the right context at the right time. Answer quality depends first on the quality of your documents and how you split them.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;the-four-steps-of-a-rag-pipeline&quot;&gt;The four steps of a RAG pipeline&lt;/h2&gt;
&lt;p&gt;Whatever the framework, a RAG system has two phases. Indexing happens once, when documents are added. Querying happens for every question.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dah-projects-and-innovations.github.io/dah-labs-site/media/articles/rag-pipeline-en.svg&quot; alt=&quot;Diagram of a RAG pipeline: documents are split into chunks, embedded and stored; each question retrieves the closest passages, which are given to the language model to produce the answer.&quot;&gt;
&lt;em&gt;Fig. 1. A RAG pipeline. Documents are indexed once; each question retrieves the closest passages before generation.&lt;/em&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Load&lt;/strong&gt; — read the source documents (PDFs, web pages, text files).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Split&lt;/strong&gt; — cut them into short passages that overlap slightly so no context is lost at the boundaries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Index&lt;/strong&gt; — turn each passage into a vector (an embedding) and store it in a vector database.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Query&lt;/strong&gt; — for each question, retrieve the closest passages and pass them to the model along with the question.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;choosing-the-chunk-size&quot;&gt;Choosing the chunk size&lt;/h3&gt;
&lt;p&gt;Passages that are too long dilute the relevant information; passages that are too short lose their context. A common starting point is a &lt;code&gt;chunk_size&lt;/code&gt; of a few hundred to a thousand characters, with a &lt;code&gt;chunk_overlap&lt;/code&gt; of 10 to 20% — then adjust by testing on real questions.&lt;/p&gt;
&lt;h3 id=&quot;measuring-similarity&quot;&gt;Measuring similarity&lt;/h3&gt;
&lt;p&gt;To find the passages closest to a question, both are turned into vectors and compared. The most common measure is cosine similarity: it looks at the angle between the two vectors rather than their length.&lt;/p&gt;
&lt;div class=&quot;math-block&quot;&gt;&#92;text{sim}(q, d) = &#92;frac{q &#92;cdot d}{&#92;lVert q &#92;rVert &#92;, &#92;lVert d &#92;rVert}
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Cosine similarity between the question vector q and a passage vector d.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;a-first-pipeline-in-python&quot;&gt;A first pipeline in Python&lt;/h2&gt;
&lt;p&gt;Here is the skeleton of the four steps with LangChain. The embedding model is up to you: a local open-source model or an API.&lt;/p&gt;
&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; langchain_community&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;document_loaders &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; PyPDFLoader
&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; langchain_text_splitters &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; RecursiveCharacterTextSplitter
&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; langchain_community&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;vectorstores &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; FAISS

&lt;span class=&quot;token comment&quot;&gt;# 1. Load&lt;/span&gt;
docs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; PyPDFLoader&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;nutrition_guide.pdf&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;load&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 2. Split&lt;/span&gt;
splitter &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; RecursiveCharacterTextSplitter&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;chunk_size&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;800&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; chunk_overlap&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
chunks &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; splitter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;split_documents&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;docs&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 3. Index&lt;/span&gt;
embeddings &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# the embedding model of your choice&lt;/span&gt;
vectorstore &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; FAISS&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;from_documents&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;chunks&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; embeddings&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# 4. Query&lt;/span&gt;
retriever &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; vectorstore&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;as_retriever&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;search_kwargs&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;dict&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;k&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
passages &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; retriever&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;invoke&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Which local foods are rich in iron?&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The retriever returns the four most relevant passages for the question. All that&#39;s left is to insert them into the prompt sent to the language model, with the instruction to answer only from that context — and to say so when the answer isn&#39;t there.&lt;/p&gt;
&lt;h2 id=&quot;going-further&quot;&gt;Going further&lt;/h2&gt;
&lt;p&gt;Once this foundation is in place, the real gains usually come from three places:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Evaluating answers on a set of test questions, so each change can be measured.&lt;/li&gt;
&lt;li&gt;Trying different embedding models, especially for French and local languages.&lt;/li&gt;
&lt;li&gt;Combining vector search with keyword search for names, codes and acronyms.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Lewis, P., Perez, E., Piktus, A., et al. (2020). &lt;em&gt;Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks&lt;/em&gt;. NeurIPS 2020. &lt;a href=&quot;https://arxiv.org/abs/2005.11401&quot;&gt;arXiv:2005.11401&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Johnson, J., Douze, M., &amp;amp; Jégou, H. (2017). &lt;em&gt;Billion-scale similarity search with GPUs&lt;/em&gt;. &lt;a href=&quot;https://arxiv.org/abs/1702.08734&quot;&gt;arXiv:1702.08734&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;LangChain documentation. &lt;a href=&quot;https://python.langchain.com&quot;&gt;python.langchain.com&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</content>
  </entry>
</feed>
