ragflow icon indicating copy to clipboard operation
ragflow copied to clipboard

[Question]: I want to become a smart legal assistant

Open charlotteren1 opened this issue 1 month ago • 6 comments

Self Checks

  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (Language Policy).
  • [x] Non-english title submitions will be closed directly ( 非英文标题的提交将会被直接关闭 ) (Language Policy).
  • [x] Please do not modify this template :) and fill in all the required fields.

Describe your problem

I want to become a legal legal assistant in ragflow. I used the gwen3:8b chat model for free. I use mxbai-embed-large as the embedding model. I don't know the necessary fine-tuning and how to write a prompt. My goal is to ask questions from the PDFs I uploaded and get the correct answer.

charlotteren1 avatar Nov 11 '25 13:11 charlotteren1

You don’t need to fine-tune the gwen3:8b model to use RAGFlow as a legal assistant—RAGFlow is designed to work by retrieving relevant content from your uploaded PDFs (using mxbai-embed-large for embeddings) and then prompting the chat model to answer based on that content. Fine-tuning is not currently supported for end users, but may be available in the future [source].

For best results, focus on prompt engineering. In RAGFlow, prompt templates let you control how the model answers. The most important variable is {knowledge}, which injects the retrieved content from your PDFs. You can also use {query} for the user’s question and {history} for previous conversation context. Here’s a simple legal Q&A prompt template:

You are a legal assistant. Answer the user's question using only the provided knowledge base. If the answer is not found, reply: "The answer you are looking for is not found in the knowledge base."
User question: {query}
Knowledge base: {knowledge}

To set this up:

  1. Upload your PDFs and make sure chunking is configured to avoid input length errors (set chunk size to 512 or 256 tokens, and ensure the Token chunker is present) [source].
  2. Use the mxbai-embed-large embedding model for document indexing.
  3. In the chat or prompt configuration, use a template like the one above. You can add custom instructions or variables as needed [source].

If you run into issues with PDF parsing or chunking, try switching parsers, splitting large PDFs, or converting them to plain text before uploading [source].

Let me know if you want more prompt examples or details on configuring your workflow!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

dosubot[bot] avatar Nov 11 '25 13:11 dosubot[bot]

RAGFlow'u yasal asistan olarak kullanmak için gwen3:8b modelini ince ayar yapmanıza gerek yok. RAGFlow, yüklediğiniz PDF'lerden ilgili içeriği alarak (gömme işlemleri için mxbai-embed-large kullanarak) ve ardından sohbet modelini bu içeriğe göre yanıt vermeye yönlendirerek çalışacak şekilde tasarlanmıştır. İnce ayar özelliği şu anda son kullanıcılar için desteklenmemektedir, ancak gelecekte kullanılabilir hale gelebilir [ kaynak ].

En iyi sonuçlar için istem mühendisliğine odaklanın. RAGFlow'da istem şablonları, modelin nasıl yanıt verdiğini kontrol etmenizi sağlar. En önemli değişken, PDF'lerinizden alınan içeriği ekleyen değişkendir . Ayrıca kullanıcının sorusu ve önceki konuşma bağlamı için {knowledge}de kullanabilirsiniz . İşte basit bir hukuki soru-cevap istemi şablonu:{query}``{history}

You are a legal assistant. Answer the user's question using only the provided knowledge base. If the answer is not found, reply: "The answer you are looking for is not found in the knowledge base."
User question: {query}
Knowledge base: {knowledge}

Bunu ayarlamak için:

  1. PDF'lerinizi yükleyin ve girdi uzunluğu hatalarını önlemek için parçalama işleminin yapılandırıldığından emin olun (parça boyutunu 512 veya 256 jetona ayarlayın ve Jeton parçalayıcısının mevcut olduğundan emin olun) [ kaynak ].
  2. Belge indeksleme için mxbai-embed-large yerleştirme modelini kullanın.
  3. Sohbet veya istem yapılandırmasında yukarıdaki gibi bir şablon kullanın. Gerektiğinde özel talimatlar veya değişkenler ekleyebilirsiniz [ kaynak ].

PDF ayrıştırma veya parçalama ile ilgili sorunlarla karşılaşırsanız, yüklemeden önce ayrıştırıcıları değiştirmeyi, büyük PDF'leri bölmeyi veya düz metne dönüştürmeyi deneyin [ kaynak ].

İş akışınızı yapılandırma konusunda daha hızlı örnekler veya ayrıntılar istiyorsanız bana bildirin!

Cevaplamak için @dosu'dan bahsetmeniz yeterli .

Nasıl yaptım? İyi | İlgisiz | Yanlış | Ayrıntılı | Halüsinasyon | Rapor 🐛 | Diğer  Dosu ile sohbet et Discord'a katılın X'te paylaş

What should I do to get the most accurate result? How should I write both the chat system prompt and the dataset prompt? @dosu

You don’t need to fine-tune the gwen3:8b model to use RAGFlow as a legal assistant—RAGFlow is designed to work by retrieving relevant content from your uploaded PDFs (using mxbai-embed-large for embeddings) and then prompting the chat model to answer based on that content. Fine-tuning is not currently supported for end users, but may be available in the future [source].

For best results, focus on prompt engineering. In RAGFlow, prompt templates let you control how the model answers. The most important variable is {knowledge}, which injects the retrieved content from your PDFs. You can also use {query} for the user’s question and {history} for previous conversation context. Here’s a simple legal Q&A prompt template:

You are a legal assistant. Answer the user's question using only the provided knowledge base. If the answer is not found, reply: "The answer you are looking for is not found in the knowledge base."
User question: {query}
Knowledge base: {knowledge}

To set this up:

  1. Upload your PDFs and make sure chunking is configured to avoid input length errors (set chunk size to 512 or 256 tokens, and ensure the Token chunker is present) [source].
  2. Use the mxbai-embed-large embedding model for document indexing.
  3. In the chat or prompt configuration, use a template like the one above. You can add custom instructions or variables as needed [source].

If you run into issues with PDF parsing or chunking, try switching parsers, splitting large PDFs, or converting them to plain text before uploading [source].

Let me know if you want more prompt examples or details on configuring your workflow!

To reply, just mention @dosu.

How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

What should I do to get the most accurate result? How should I write both the chat system prompt and the dataset prompt?

charlotteren1 avatar Nov 11 '25 13:11 charlotteren1

For the most accurate results as a legal assistant in RAGFlow, focus on prompt engineering and document chunking. Use the mxbai-embed-large embedding model and set your chunk size to 256 or 512 tokens to avoid input length errors. If you have parsing issues, try a different parser or convert your PDFs to plain text.

For both the chat system prompt and the dataset prompt, use variables to inject context: {knowledge} for retrieved PDF content, {query} for the user's question, and {history} for conversation context. Here’s a strong template:

You are a legal assistant. Answer the user's question using only the provided knowledge base. If the answer is not found, reply: "The answer you are looking for is not found in the knowledge base."
User question: {query}
Knowledge base: {knowledge}

You can customize this further, but always ensure the model is instructed to answer strictly from the provided knowledge. The prompt editor in RAGFlow lets you insert these variables interactively and supports dynamic updates as you edit your template, making it easy to experiment and refine your prompts for legal Q&A tasks. Prompt customization is central to getting accurate answers in specialized domains like law.
Source: prompt editor code

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

dosubot[bot] avatar Nov 11 '25 13:11 dosubot[bot]

Always RAG instead of fine-tuning. 8B is far beyond feasible.

KevinHuSh avatar Nov 12 '25 05:11 KevinHuSh

Her zaman RAGyerine fine-tuning. 8Bkullanmak mümkün olmaktan çok ötedir.

Do you have any suggestions for the system I mentioned, such as how to start and what to pay attention to, or which model would be better for me to use?

charlotteren1 avatar Nov 12 '25 05:11 charlotteren1

For LLM, the larger the better.

KevinHuSh avatar Nov 18 '25 01:11 KevinHuSh

Since there has been no further activity for over three weeks, we will proceed to close this issue. If the problem persists or you have additional questions, please feel free to reopen the issue or create a new one. We’re happy to assist anytime.

Magicbook1108 avatar Dec 16 '25 11:12 Magicbook1108