ReZanAi is a Retrieval-Augmented Generation (RAG) based AI model designed to provide accurate, context-aware advice and interpretation of the Constitution of the Republic of Kazakhstan. By combining powerful language models with a custom retrieval system over constitutional text, ReZanAi delivers precise, citation-backed answers to legal and civic queries.
- Contextual Retrieval: Dynamically fetches relevant constitutional articles and commentary based on user queries.
- Augmented Generation: Leverages state-of-the-art LLMs to generate clear, well-structured explanations and advice.
- Citation Support: Integrates direct references to constitutional articles and amendments in responses for transparency.
- Multi‑Language Interface: Supports both Kazakh and English queries and responses.
- Extensible Data Sources: Easily plug in additional legal texts, amendments, or scholarly commentary.
- Getting Started
- Prerequisites
- Installation
- Usage
- Architecture Overview
- RAG Implementation Details
- Data Sources
- Fine-Tuning the Model
- API Reference
- Contributing
- License
- Acknowledgements
Follow these instructions to set up a local development environment and run ReZanAi.
- Python 3.9+
- Git
- Poetry or pip
-
Clone the repository
git clone https://github.com/your_org/ReZanAi.git cd ReZanAi -
Install dependencies
# Or using pip pip install -r requirements.txt -
Configure environment variables
cp .env.example .env # Edit .env to add your LLM_API_KEY and any other settings
To start the interactive query interface:
python run_app.pyExample:
> What does Article 33 say about language policy?
ReZanAi: Article 33 of the Constitution of Kazakhstan guarantees the right to choose the language of instructions and communication. It states that Kazakh is the state language, but everyone has the right to use any language they choose in private and public settings.ReZanAi comprises three main components:
- Document Store: A vector database indexing all articles of the Constitution and supplemental commentary.
- Retrieval Module: Queries the vector store to retrieve top‑k relevant passages for a given question.
- Generation Module: An LLM that synthesizes retrieved passages into a coherent response, appending citations.
-
Embedding Model: Uses SentenceTransformers to encode constitutional text into embeddings.
-
Vector Database: Supports both FAISS (local) and Weaviate or Pinecone (managed).
-
Retriever Settings:
- Similarity Metric: Cosine distance
- Top‑k Retrieval: Configurable (default: k = 5)
-
LLM Prompts: Structured prompt template that includes:
- System instructions outlining role and citation format.
- Retrieved passages with inline article references.
- User query.
- Primary Text: Official Constitution of the Republic of Kazakhstan (1995, amended 2022).
- Language Versions: Both Kazakh and English translations.
- Supplemental Commentary: Select scholarly articles and government explanations.
If you wish to fine-tune the LLM on legal Q&A data, follow these steps:
-
Prepare a JSONL file of
{"prompt": ..., "completion": ...}pairs. -
Run:
openai api fine_tunes.create -t legal_qa.jsonl -m <base-model>
-
Update
MODEL_NAMEin.envto your fine-tuned model.
We welcome contributions! Please:
- Fork the repo
- Create a feature branch (
git checkout -b feature/YourFeature) - Commit your changes (
git commit -m 'Add new feature') - Push to the branch (
git push origin feature/YourFeature) - Open a Pull Request
Refer to CONTRIBUTING.md for detailed guidelines.
This project is released under the MIT License.
- SentenceTransformers team
- The Government of the Republic of Kazakhstan for constitutional texts
ReZanAi © 2025 Your Organization. All rights reserved.