text
𝗔𝗱𝗱 𝘀𝗼𝘂𝗿𝗰𝗲 𝗵𝗶𝗴𝗵𝗹𝗶𝗴𝗵𝘁𝗶𝗻𝗴 𝘁𝗼 𝘆𝗼𝘂𝗿 𝗥𝗔𝗚 𝘀𝘆𝘀𝘁𝗲𝗺! 📄💡
𝗔𝗱𝗱 𝘀𝗼𝘂𝗿𝗰𝗲 𝗵𝗶𝗴𝗵𝗹𝗶𝗴𝗵𝘁𝗶𝗻𝗴 𝘁𝗼 𝘆𝗼𝘂𝗿 𝗥𝗔𝗚 𝘀𝘆𝘀𝘁𝗲𝗺! 📄💡
new_line
new_line
text
RAG systems are supposed to make your LLM's answer more trustworthy, by inserting in the prompt some supporting documents from a knowledge base : we say that we're "adding some context". 
RAG systems are supposed to make your LLM's answer more trustworthy, by inserting in the prompt some supporting documents from a knowledge base : we say that we're "adding some context". 
new_line
new_line
text
👎 But if you don't know which part of the answer has been generated based on which input tokens, it's hard to tell wether it was effectively grounded in the context knowledge or not!
👎 But if you don't know which part of the answer has been generated based on which input tokens, it's hard to tell wether it was effectively grounded in the context knowledge or not!
new_line
new_line
text
🤔 I've been working on the question: is it possible to add notes to the answer linking to which part of the context they're generated from?
🤔 I've been working on the question: is it possible to add notes to the answer linking to which part of the context they're generated from?
new_line
new_line
text
And I've found a great solution: a great technique called Layer-wise Relevance Propagation (LRP), showcased in a paper at ICML `24 by Reduan Achtibat et al allows, allows to precisely score how important each input token was in generating your output! They've made it into a library called LXT.
And I've found a great solution: a great technique called Layer-wise Relevance Propagation (LRP), showcased in a paper at ICML `24 by Reduan Achtibat et al allows, allows to precisely score how important each input token was in generating your output! They've made it into a library called LXT.
new_line
new_line
text
📊 For each generated output token, LXT gives you attribution scores for each input token.
📊 For each generated output token, LXT gives you attribution scores for each input token.
new_line
new_line
text
⚙️ So I've worked a bit more on aggregating these scores into meaningful spans between successive input and output tokens, and I finally obtained my desired result: RAG with source highlighting!
⚙️ So I've worked a bit more on aggregating these scores into meaningful spans between successive input and output tokens, and I finally obtained my desired result: RAG with source highlighting!
new_line
new_line
text
Try the demo here 👉 
Try the demo here 👉 
resource
https://huggingface.co/spaces/m-ric/rag_highlights
space
m-ric/rag_highlights
https://huggingface.co/spaces/m-ric/rag_highlights
new_line
new_line
text
Caveats:
Caveats:
new_line
text
- It slows down generation (for now quite a lot, could hopefully be reduced a lot)
- It slows down generation (for now quite a lot, could hopefully be reduced a lot)
new_line
text
- For now it supports only specific models: Llama models and Mixtral
- For now it supports only specific models: Llama models and Mixtral
new_line
new_line
text
If there's enough interest in this solution, I can improve it further and spin it off into a specific library for RAG! 🚀
If there's enough interest in this solution, I can improve it further and spin it off into a specific library for RAG! 🚀
𝗔𝗱𝗱 𝘀𝗼𝘂𝗿𝗰𝗲 𝗵𝗶𝗴𝗵𝗹𝗶𝗴𝗵𝘁𝗶𝗻𝗴 𝘁𝗼 𝘆𝗼𝘂𝗿 𝗥𝗔𝗚 𝘀𝘆𝘀𝘁𝗲𝗺! 📄💡

RAG systems are supposed to make your LLM's answer more trustworthy, by inserting in the prompt some supporting documents from a knowledge base : we say that we're "adding some context". 

👎 But if you don't know which part of the answer has been generated based on which input tokens, it's hard to tell wether it was effectively grounded in the context knowledge or not!

🤔 I've been working on the question: is it possible to add notes to the answer linking to which part of the context they're generated from?

And I've found a great solution: a great technique called Layer-wise Relevance Propagation (LRP), showcased in a paper at ICML `24 by Reduan Achtibat et al allows, allows to precisely score how important each input token was in generating your output! They've made it into a library called LXT.

📊 For each generated output token, LXT gives you attribution scores for each input token.

⚙️ So I've worked a bit more on aggregating these scores into meaningful spans between successive input and output tokens, and I finally obtained my desired result: RAG with source highlighting!

Try the demo here 👉 https://huggingface.co/spaces/m-ric/rag_highlights

Caveats:
- It slows down generation (for now quite a lot, could hopefully be reduced a lot)
- For now it supports only specific models: Llama models and Mixtral

If there's enough interest in this solution, I can improve it further and spin it off into a specific library for RAG! 🚀
🚀
louisbrulenaudet KingNish brianjking John6666 Xdotnet StephenGenusa
👍
brianjking aitimer tiendung chadrick VicidiLochi
😎
tiendung
🔥
AIAJAY