Semantic retrieval finds relevant information by understanding the meaning behind your query, not just matching keywords. It uses embeddings to search through your knowledge base and return the most contextually relevant documents.
Pawa AI make implement advanced mathematics that make it ease and accurate for you to search exactly the simmilar informations on the documents by just sending request to our api
Semantic Retrieval Example
How it works
- Index your documents into Pawa AI’s knowledge base
- Query with natural language - ask questions in plain English or Swahili
- Get ranked results - most relevant documents appear first based on semantic similarity
- Use in RAG or elsewhere - feed retrieved context to chat models for grounded answers
This is the FREE endpoint, not cost associated with it. After creating knowledge base with Pawa AI , you can use the retrieval endpoint to get the top-k relevant results, that can be used in your RAG or else use cases.
What you can build
- Intelligent search across documents, PDFs, and knowledge bases
- Question answering systems that find relevant context
- Content recommendations based on semantic similarity
- Document discovery for large repositories
- Customer support with instant access to relevant help articles
Using Pawa AI Knowledge Base
Pawa AI provides a managed knowledge base with built-in semantic retrieval. Upload your documents and query them naturally.
To learn more knowledge base in Pawa AI, see here.
1. Create a Knowledge Base & Upload documents
curl --request POST \
--url https://api.pawa-ai.com/v1/store/knowledge-base \
--header "Authorization: Bearer $PAWA_AI_API_KEY" \
--header 'Content-Type: multipart/form-data' \
--form 'name=WCF Knowledgebase' \
--form 'description=This is the knowledgebase about WCF (Workers compensation fund) in Tanzania......etc...' \
--form knowledgeBase=@67f22be974bbec7dacd9cfdb.pdf
2. Semantic Search across your knowledge
curl --request POST \
--url https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval \
--header "Authorization: Bearer $PAWA_AI_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"knowledge_base_id": "23",
"question_asked_by_user": "When WCF got started?"
}'
{
"finalRelevantChunk": [
"Hello Pawa AI, I am the final relevant chunk you need"
],
"filteredResults": [
{
"id": 63,
"knowledgeBaseId": 7,
"documentName": "131.3-Visa-Requirements-Schengen-2021-05 (1) (1).pdf",
"chunk": "and for the whole period of staying in the Schengen area. In order to have a flexible travel schedule it is suggested to issue the Insurance for a few days longer than the planned travel time...",
"distance": 0.7506968916261936
},
{
"id": 76,
"knowledgeBaseId": 7,
"documentName": "131.3-Visa-Requirements-Schengen-2021-05 (1) (1).pdf",
"chunk": "plan agreed with the clinic. Medical health documentation issued by the applicant’s country of residence...",
"distance": 0.7515738980069386
}
]
Integration retrieval with Chat Setup
Combine semantic retrieval with chat models for powerful RAG applications:
# 1. Search for relevant context
curl --request POST \
--url https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval \
--header "Authorization: Bearer $PAWA_AI_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"knowledge_base_id": "23",
"question_asked_by_user": "When WCF got started?"
}'
# 2. Use retrieved context in chat
curl https://api.pawa-ai.com/v1/chat/request \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PAWA_AI_API_KEY" \
-d '{
"model": "pawa-v1-blaze-20250318",
"messages": [
{
"role": "system",
"content": "Answer based on the provided context. If you cannot find the answer in the context, say so."
},
{
"role": "user",
"content": "Context: [retrieved documents]\n\nQuestion: How do I request time off?"
}
]
}'
Best Practices
- Use descriptive queries: “What are the steps to file a complaint?” vs “complaint”
- Optimize chunk size: 500-1000 characters work well for most documents
- Filter by metadata: Use file types, dates, or categories to narrow results
- Combine with keywords: Use both semantic and keyword search for comprehensive results
- Monitor relevance scores: Adjust top_k based on score thresholds
Multi-language Support
Query in English or Swahili - Pawa AI understands both:
# English query
"Find information about employee benefits"
# Swahili query
"Tafuta taarifa kuhusu faida za wafanyakazi"
Troubleshooting
- Low relevance scores: Try rephrasing queries or checking document quality
- Missing results: Ensure documents are properly indexed and not corrupted
- Slow responses: Reduce top_k or optimize document chunk sizes
- Language mismatch: Query in the same language as your documents for best results
Limits
- Maximum query length: 1000 characters
- Maximum documents per knowledge base: depends on your plan
- Response time: typically under 2 seconds for most queries