पाठ 13 / 27
Query Rewriting और Expansion
अव्यवस्थित user सवालों को अच्छी search queries में बदलें।
Users search queries नहीं लिखते
असली सवाल छोटे, अस्पष्ट या पिछले turns पर निर्भर होते हैं ("और contractors का क्या?")। खोज से पहले उन्हें सुधारें: (1) chat इतिहास और follow-up को स्वतंत्र सवाल में संघनित करें; (2) पर्यायवाची और संबंधित शब्दों से विस्तार करें; (3) जटिल सवाल को कई उप-सवालों में बाँटें और हर एक खोजें (multi-query); (4) HyDE, जहाँ मॉडल काल्पनिक उत्तर का मसौदा बनाता है और आप उसी पाठ से खोजते हैं। हर rewrite एक मॉडल call जोड़ती है और user के आशय से भटक सकती है, इसलिए खोज में मूल query भी रखें और मापें कि rewrite वाक़ई मदद करती है या नहीं।
बेहतर पूछें, बेहतर rank करें, कम भेजें
Queries दोबारा लिखें, उम्मीदवार rerank करें, परिणाम विविध करें और तय करें कितने chunks भेजने हैं।
Follow-up संघनित करना (prompt template)
Follow-up को स्वतंत्र सवाल बनाने का template। यहाँ चलाया नहीं गया।
Given the chat history and the follow-up question, rewrite the follow-up as a
single standalone question that includes all needed context. Do not answer it.
History:
User: How many leave days do employees get?
Assistant: 24 days per year.
Follow-up: and contractors?
Standalone question: How many paid leave days do contractors get per year?त्वरित जाँच: Retrieval से पहले follow-up सवाल क्यों संघनित करें?
- बिना कारण query लंबी करने के लिए
- "and contractors?" अकेले में खोजने योग्य संदर्भ नहीं है
- Embeddings से बचने के लिए
- इतिहास हटाने के लिए
Answer
"and contractors?" अकेले में खोजने योग्य संदर्भ नहीं है — स्वतंत्र सवाल वह अर्थ रखता है जो retriever को चाहिए।