Collective is looking for a Senior RAG Engineer (freelance) to build a reliable, sourced, and traceable AI-powered legal knowledge platform for Morocco and Africa. You will own the entire user question → relevant excerpts → reliable and sourced answer pipeline, making the RAG engine measurable, stable, and improvable.
What You'll Do
- Design and implement robust retrieval on a legal corpus using dense (embeddings) and hybrid (BM25 + embeddings) search.
- Implement metadata filters based on text type, date, jurisdiction, and version.
- Set up reranking with cross-encoders or rerankers to improve result precision.
- Define a query understanding strategy, including query rewriting, multi-query, expansion with legal synonyms, and long query management.
- Build end-to-end evaluation: create a QA dataset and annotation guidelines, track metrics like Recall@k, MRR, and nDCG, run regression tests, and perform error analysis.
- Implement grounding and citation mechanisms for source-based answers, precise citations (document/page/section), and controlled 'no-answer' handling.
What We're Looking For
- 4+ years of experience in Search, Information Retrieval, Ranking, or ML applied to relevance.
- Strong proficiency in Python.
- A strong culture of metrics and experimentation, with a proven ability to improve via measurement.
- Ability to build robust production systems with a focus on quality, performance, and instrumentation.
- Professional mastery of French, with the ability to perform fine reading and relevance judgment on legal content.
Nice to Have
- Experience with LegalTech, regulatory corpus, litigation, or case law.
- Experience with multilingual French/Arabic data.
- Experience with LLMOps, answer quality monitoring, or guardrails.
- Experience with A/B testing or experimentation frameworks.
Technical Stack
- BM25: OpenSearch/Elasticsearch
- Embeddings / vector search: FAISS, pgvector, OpenSearch vector
- Reranking: cross-encoders / rerankers (HuggingFace, specialized models)
- RAG orchestration: LangChain / LlamaIndex (nice-to-have)
- Evaluation: test pipelines, notebooks/CI, metric dashboards
- Cloud: AWS
Work Mode
This is a local freelance position based in Casablanca.
Collective is an equal opportunity employer.





