تواجه أنظمة الجيل المعزز بالاسترجاع (RAG) تحديات في الحفاظ على الدقة والكفاءة عند التعامل مع نوافذ سياق كبيرة ومكونات استرجاع وتوليد منفصلة. يعالج إطار عمل جديد، CLaRa (الاستدلال الكامن المستمر)، الذي طوره باحثو Apple، هذه المشكلات عن طريق ضغط المستندات إلى رموز ذاكرة مستمرة وتنفيذ الاسترجاع والتوليد في مساحة كامنة مشتركة. يهدف هذا النهج إلى تقصير السياق وتجنب التشفير المزدوج وتحسين النظام من خلال السماح للمولد بتوجيه المسترجع بشأن المعلومات الأكثر صلة.
المفاهيم الأساسية لـ CLaRa
- الضغط الدلالي: تستخدم CLaRa ضاغطًا دلاليًا لإرفاق عدد صغير من رموز الذاكرة المتعلمة بكل مستند. يتم تحقيق هذا الضغط أثناء التدريب المسبق للضاغط البارز (SCP)، حيث يقوم محول Mistral 7B مع محولات LoRA بالتبديل بين أدوار الضاغط والمولد. تصبح الحالات المخفية للطبقة النهائية لرموز الذاكرة هي التمثيل المضغوط للمستند.
- الاسترجاع والتوليد المشترك: بعد الضغط في وضع عدم الاتصال، يتم تمثيل كل مستند فقط برموز الذاكرة الخاصة به. تدرب CLaRa سببًا للاستعلام ومولدًا للإجابات فوق نفس العمود الفقري. يقوم سبب الاستعلام بتعيين سؤال إدخال إلى رموز الذاكرة. يصبح الاسترجاع بحثًا بسيطًا عن تشابه جيب التمام بين تضمين الاستعلام وتضمينات المستند المرشح. ثم يتم ربط أفضل تضمينات المستند المضغوط برموز الاستعلام وتغذيتها في محول المولد.
- تحديد أفضل k قابل للتفاضل: يتمثل الابتكار الرئيسي في استخدام محدد أفضل k قابل للتفاضل، يتم تنفيذه باستخدام مقدر Straight-Through. أثناء المرور الأمامي، يستخدم النموذج تحديدًا صعبًا لأفضل k. أثناء المرور الخلفي، يسمح توزيع softmax عبر درجات المستندات بتدفق التدرجات من المولد إلى معلمات سبب الاستعلام. هذا يشجع المسترجع على تحديد أولويات المستندات التي تحسن احتمالية الإجابة.
التدريب والتقييم
- التدريب المسبق للضاغط البارز (SCP): يتم التدريب على ما يقرب من 2 مليون مقطع من ويكيبيديا 2021، يستخدم SCP نموذج Qwen-32B لإنشاء إشارات إشرافية، بما في ذلك أزواج QA البسيطة وأزواج QA المعقدة وإعادة الصياغة. تضمن حلقة التحقق الاتساق الواقعي والتغطية.
- خسائر التدريب: يتضمن التدريب مصطلحي خسارة: مصطلح إنتروبيا متقاطع لتدريب المولد ومصطلح متوسط مربع الخطأ (MSE) لمحاذاة الحالة المخفية المتوسطة لرموز المستند مع الحالة المخفية المتوسطة لرموز الذاكرة. يوفر فقدان MSE مكاسب ثابتة من خلال الحفاظ على التمثيلات المضغوطة والأصلية في نفس المنطقة الدلالية.
- مجموعات بيانات QA: يتم تقييم الضاغط على مجموعات بيانات مثل الأسئلة الطبيعية و HotpotQA و MuSiQue و 2WikiMultihopQA. تظهر النتائج أن CLaRa يمكن أن تتفوق على طرق الضغط والاسترجاع الحالية، خاصة في الإعدادات التي يكون فيها المستند الصحيح ضمن المجموعة المرشحة.
أبرز الأداء
- تحقق CLaRa تحسينات كبيرة في درجات F1 مقارنة بخطوط الأساس مثل LLMLingua-2 و PISCO، حتى أنها تتفوق على مسترجع النصوص القائم على BGE بالإضافة إلى مولد Mistral-7B للمستند الكامل.
- يحافظ النظام على أداء معتدل حتى في نسب الضغط العالية (أكثر من 32x)، مع كون الاختناق الرئيسي هو ضعف ملاءمة المستند بدلاً من جودة الضغط.
- في مهام QA الشاملة، تُظهر CLaRa أداءً قابلاً للمقارنة أو أفضل قليلاً من DRO-Mistral-7B، الذي يستخدم نصًا كاملاً غير مضغوط، مع استخدام تمثيلات مستند أقصر 16 مرة.
- تؤدي CLaRa أيضًا بقوة كمعيد ترتيب، حيث تحقق استدعاءً عاليًا عند 5، متجاوزًا خطوط BGE Reranker الخاضعة للإشراف.
إصدارات النموذج
أصدرت Apple ثلاثة نماذج على Hugging Face:
- CLaRa-7B-Base
- CLaRa-7B-Instruct (نموذج RAG موحد مضبوط على التعليمات مع ضغط مستند مدمج بمعدل 16x و 128x)
- CLaRa-7B-E2E
الوجبات السريعة الرئيسية
- تستفيد CLaRa من الضغط الدلالي الموجه بـ QA والموجه بإعادة الصياغة لاستبدال المستندات الأولية برموز ذاكرة مستمرة، مع الحفاظ على إشارات الاستدلال حتى في نسب الضغط العالية.
- يتم تدريب الاسترجاع والتوليد بشكل مشترك في مساحة كامنة مشتركة، مما يحسن كلا المكونين بخسارة واحدة لنمذجة اللغة.
- يسمح مقدر أعلى k قابل للتفاضل بتدفق التدرجات من رموز الإجابة إلى المسترجع، مما يؤدي إلى مواءمة ملاءمة المستند مع جودة الإجابة.
- تتفوق CLaRa على خطوط الأساس النصية القوية في معايير QA متعددة القفزات ويمكنها حتى التغلب على خطوط أنابيب BGE / Mistral النصية الكاملة.
- أصدرت Apple نماذج عملية وخط أنابيب التدريب الكامل، مما يجعل الإطار متاحًا لمزيد من البحث والتطوير.
في الختام، يمثل CLaRa تقدمًا كبيرًا في أنظمة RAG من خلال دمج ضغط المستندات الدلالية والتحسين المشترك في مساحة مستمرة مشتركة. يقدم هذا النهج بديلاً مقنعًا لطرق RAG التقليدية للتجميع والاسترجاع، مما يتيح الإجابة على الأسئلة بكفاءة ودقة مع أطوال سياق أقصر بشكل ملحوظ.
المصدر: MarkTechPost
Retrieval-Augmented Generation (RAG) systems face challenges in maintaining accuracy and efficiency when dealing with large context windows and disconnected retriever and generator components. A new framework, CLaRa (Continuous Latent Reasoning), developed by Apple researchers, addresses these issues by compressing documents into continuous memory tokens and performing retrieval and generation in a shared latent space. This approach aims to shorten context, avoid double encoding, and optimize the system by allowing the generator to guide the retriever on what information is most relevant.
Key Concepts of CLaRa
- Semantic Compression: CLaRa uses a semantic compressor to attach a small number of learned memory tokens to each document. This compression is achieved during Salient Compressor Pretraining (SCP), where a Mistral 7B-style transformer with LoRA adapters switches between compressor and generator roles. The final layer hidden states of the memory tokens become the compressed representation for the document.
- Joint Retrieval and Generation: After offline compression, each document is represented solely by its memory tokens. CLaRa trains a query reasoner and an answer generator on top of the same backbone. The query reasoner maps an input question into memory tokens. Retrieval becomes a simple cosine similarity search between the query embedding and candidate document embeddings. The best compressed document embeddings are then concatenated with the query tokens and fed into the generator adapter.
- Differentiable Top-k Selection: A key innovation is the use of a differentiable top-k selector, implemented with a Straight-Through estimator. During the forward pass, the model employs hard top-k selection. During the backward pass, a softmax distribution over document scores allows gradients from the generator to flow into the query reasoner parameters. This encourages the retriever to prioritize documents that improve answer likelihood.
Training and Evaluation
- Salient Compressor Pretraining (SCP): Trained on approximately 2 million passages from Wikipedia 2021, SCP uses a Qwen-32B model to generate supervision signals, including simple QA pairs, complex QA pairs, and paraphrases. A verification loop ensures factual consistency and coverage.
- Training Losses: Training involves two loss terms: a cross-entropy term to train the generator and a mean squared error (MSE) term to align the average hidden state of document tokens with the average hidden state of the memory tokens. The MSE loss provides consistent gains by keeping compressed and original representations in the same semantic region.
- QA Datasets: The compressor is evaluated on datasets like Natural Questions, HotpotQA, MuSiQue, and 2WikiMultihopQA. Results show that CLaRa can outperform existing compression and retrieval methods, especially in settings where the correct document is within the candidate set.
- CLaRa achieves significant improvements in F1 scores compared to baselines like LLMLingua-2 and PISCO, even outperforming a BGE-based text retriever plus full document Mistral-7B generator.
- The system maintains moderate performance even at high compression ratios (above 32x), with the main bottleneck being weak document relevance rather than compression quality.
- In end-to-end QA tasks, CLaRa demonstrates comparable or slightly better performance than DRO-Mistral-7B, which uses full uncompressed text, while utilizing 16 times shorter document representations.
- CLaRa also performs strongly as a reranker, achieving high Recall at 5, surpassing supervised BGE Reranker baselines.
Model Releases
Apple has released three models on Hugging Face:
- CLaRa-7B-Base
- CLaRa-7B-Instruct (an instruction-tuned unified RAG model with built-in document compression at 16x and 128x)
- CLaRa-7B-E2E
Key Takeaways
- CLaRa leverages QA-guided and paraphrase-guided semantic compression to replace raw documents with continuous memory tokens, preserving reasoning signals even at high compression ratios.
- Retrieval and generation are jointly trained in a shared latent space, optimizing both components with a single language modeling loss.
- The differentiable top-k estimator allows gradients to flow from answer tokens to the retriever, aligning document relevance with answer quality.
- CLaRa outperforms strong text-based baselines on multi-hop QA benchmarks and can even beat full-text BGE/Mistral pipelines.
- Apple has released practical models and the full training pipeline, making the framework accessible for further research and development.
In conclusion, CLaRa represents a significant advancement in RAG systems by integrating semantic document compression and joint optimization in a shared continuous space. This approach offers a compelling alternative to traditional chunk-and-retrieve RAG methods, enabling efficient and accurate question answering with significantly shorter context lengths.
Source: MarkTechPost
جاري تحميل التعليقات...