Ensuring an AI Assistant Uses Uploaded Legal Documents Instead of Model-Generated Responses

I’m using an OpenAI assistant and have uploaded 500 well-formatted legal documents into a vector store. Overall, the assistant works great using the gpt-4o-mini model.

However, I’ve noticed that around 70% of its answers seem to come directly from the language model rather than from the documents I provided.

while the System command is :

You are a lawyer. Follow these instructions for all responses:

  • Format your entire response in Markdown format.
  • Answer based on the attached files only. If you do not have enough information, answer with: (I do not have enough information).
  • Answer in Arabic.
  • Be very specific and concise and avoid exaggeration.
  • Assume the role of a Saudi lawyer.
  • Always refer to relevant legal texts, including specific article numbers and dates.
  • Mention any recent updates or amendments to the laws you cite.
  • For each relevant law you mention, provide a brief summary of the relevant part of the law.
  • Use appropriate formal and legal language.
  • You do not have the authority to provide any type of judgment.
  • Your only task is to find an answer from the attached files and only.
    Your answer must adhere to all of the above guidelines.

My goal is to create a law-focused assistant that relies on the uploaded legal texts—not one that invents new laws from its imagination.

That defeats the purpose. Ideally, the assistant should reference only the information contained in the vector store. Yet, it keeps generating inaccuracies when it goes “off-script” and fabricates answers.

In other words, the assistant should be guided by a single objective: to search the documents in the vector store and base its answers on real legal references.

If it continues relying heavily on the LLM’s content, it risks delivering incorrect or misleading responses, which is unacceptable for a legal application.

This is the holy grail of RAG, so unfortunately if there was a solution it wouldn’t be shared.

Realistically you are going to need your own specialized vector database that you have fine-grained control over. Using a general-purpose retrieval system like Assistants is just not going to cut it.

Thank you for your response. As I mentioned, we’ve already uploaded our legal database, which is now converted into vectors for use with the assistant.

RAG (Retrieval-Augmented Generation) works well for general information and coding, where minor deviations can be acceptable. However, when it comes to systematic legal matters, even a small error can be a major red flag. In legal contexts, accuracy is paramount, and relying on a model that might introduce imaginative or inaccurate details is risky.

I’m still unsure how best to optimize RAG for these specialized needs, and I appreciate any insights or suggestions you might have.

Don’t use 4o mini. It doesn’t respond well to systemprompts like yours.
Try 4o. It will be better