Sovereign AI Ecosystem

Reciprocal rank fusion [chapter] deterministic

scores = {} for i, doc in enumerate(vector_results): scores[doc["id"]] = scores.get(doc["id"], 0) + 1.0 / (i + 1) for i, doc in enumerate(keyword_results): scores[doc["id"]] = scores.get(doc["id"], 0)

scores = {} for i, doc in enumerate(vector_results): scores[doc["id"]] = scores.get(doc["id"], 0) + 1.0 / (i + 1) for i, doc in enumerate(keyword_results): scores[doc["id"]] = scores.get(doc["id"], 0) + 1.0 / (i + 1) sorted_docs = sorted(scores.items(), key=lambda x: x[1], reverse=True) return [doc for doc_id, _ in sorted_docs for doc in [next(d for d in vector_results if d["id"] == doc_id)]]

`

Multi‑Hop RAG Multi‑hop RAG handles queries that require reasoning over multiple pieces of information. The iteratively retrieves documents, extracts intermediate facts, and then issues a new query based on those facts. This pattern is essential for complex questions such as “Who directed the film that won the award for best screenplay in 2023?”

Dynamic Persona MoE RAG Dynamic Persona Mixture‑of‑Experts RAG (MoE RAG) introduces specialized retrieval experts tailored to different domains or personas. Each expert is a lightweight model that processes a subset of the corpus and returns a tailored set of candidates. The selects the most appropriate expert based on the ’s context. However, this architecture can encounter **Unsupported Patterns**—specific sequences or structures that the cannot process correctly. For example, a chunk that contains a malformed JSON payload may break the parsing logic. To mitigate this, implement validation checks that detect and gracefully handle unsupported patterns before they reach the generation stage.

```python def validate_chunk(chunk: str) -> bool:

Sources

Sovereign AI: Building Local-First Intelligent Systems (book) · source

Related (0)

No recorded relationships.

← all Book