Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions app/processing/expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ def generate_hypothetical_document(query: str) -> str:
Uses a local LLM via Ollama to generate a hypothetical textbook answer
for the user's query. This is the core of the HyDE algorithm.
"""
# The system prompt forces the LLM to write like a document in your database,
# rather than acting like a chat assistant.

prompt = (
"You are an expert technical writer. Write a single, concise, factual, "
"and highly technical textbook paragraph that directly answers the following "
"search query. Do not include conversational filler, introductions, or conclusions. "
f"Query: {query}"
"You are an expert search engine query expander. Your task is to take a short user query "
"and generate a highly detailed, technical and non technical extended description that represents what the ideal "
"target document would look like. \n\n"
"Rules:\n"
"1.If the query is technical,write a 2-3 sentence technical paragraph exlpaining the core concepts of the query. \n"
"2.If its non-technical , generate a description/intoduction of the query. \n"
"3. Naturally weave in relevant synonyms, alternate phrasing, and associated technical and non technical keywords.\n"
"4. Output ONLY the extended description. Do not include introductory phrases, labels, or conversational filler.\n\n"
f"User Query: {query}"
)

payload = {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ services:
- ollama_data:/root/.ollama
restart: unless-stopped


volumes:
postgres_data:
ollama_data:
Loading