Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Feature/add rag to synthesizer (#133)
Browse files Browse the repository at this point in the history
* add output

* remove broken pdf build

* update model

* tally distribution

* add rag
  • Loading branch information
emrgnt-cmplxty authored Dec 19, 2023
1 parent fdca94b commit fffcb67
Show file tree
Hide file tree
Showing 7 changed files with 570 additions and 12 deletions.
26 changes: 24 additions & 2 deletions docs/source/setup/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,30 @@ For additional details, refer to the `installation guide <https://sciphi.readthe

Using Synthesizer
-----------------
1. **Run with RAG**

1. **Generate synthetic question answer pairs**
.. code-block:: shell
export SCIPHI_API_KEY=MY_SCIPHI_API_KEY
# Queries AgentSearch and passes results on to the SciPhi Sensei
python -m agent_search.scripts.run_rag run --query="Your Search Query" --rag_provider_name="agent-search"
.. code-block:: shell
export SCIPHI_API_KEY=MY_SCIPHI_API_KEY
export SERP_API_KEY=MY_SERP_API_KEY # refer to https://serpapi.com
# Queries Google and passes results on to the SciPhi Sensei
python -m agent_search.scripts.run_rag run --query="Your Search Query" --rag_provider_name=google-search
.. code-block:: bash
tail augmented_output/config_name_eq_answer_question__dataset_name_eq_wiki_qa.jsonl
{ "formatted_prompt": "... ### Question:\nwhat country did wine originate in\n\n### Input:\n1. URL: https://en.wikipedia.org/wiki/History%20of%20wine (Score: 0.85)\nTitle:History of wine....",
{ "completion": Wine originated in the South Caucasus, which is now part of modern-day Armenia ...
2. **Generate synthetic question answer pairs**
.. code-block:: bash
Expand All @@ -40,7 +62,7 @@ Using Synthesizer
{ "formatted_prompt": "... ### Question:\nwhat country did wine originate in\n\n### Input:\n1. URL: https://en.wikipedia.org/wiki/History%20of%20wine (Score: 0.85)\nTitle:History of wine....",
{ "completion": Wine originated in the South Caucasus, which is now part of modern-day Armenia ...
2. **Evaluate RAG pipeline performance**
3. **Evaluate RAG pipeline performance**
.. code-block:: bash
Expand Down
6 changes: 5 additions & 1 deletion synthesizer/config/prompts/answer_question.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions synthesizer/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ class LLMProviderName(Enum):
class RAGProviderName(Enum):
LOCAL = "local"
AGENT_SEARCH = "agent-search"
GOOGLE_SEARCH = "google-search"
6 changes: 6 additions & 0 deletions synthesizer/interface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
AgentSearchRAGConfig,
AgentSearchRAGInterface,
)
from synthesizer.interface.rag.google_search import (
GoogleSearchRAGConfig,
GoogleSearchRAGInterface,
)
from synthesizer.interface.rag.local import LocalRAGInterface
from synthesizer.interface.rag_interface_manager import RAGInterfaceManager

Expand All @@ -38,4 +42,6 @@
"LocalRAGInterface",
"AgentSearchRAGConfig",
"AgentSearchRAGInterface",
"GoogleSearchRAGConfig",
"GoogleSearchRAGInterface",
]
9 changes: 0 additions & 9 deletions synthesizer/interface/rag/agent_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,3 @@ def get_rag_context(self, query) -> list[str]:
for i, result in enumerate(results)
]
)

# logging.info(
# f"{i}. \033[94mURL: {result.url}\033[0m (Score: \033[95m{result.score:.2f}\033[0m)"
# )
# logging.info("-" * 50)
# logging.info(f"Title: \033[93m{result.title}\033[0m")
# logging.info(f"Text:\n{result.text}\n")
# # logging.info(f"Metadata:\n{result.metadata}...")
# logging.info("-" * 80)
Loading

0 comments on commit fffcb67

Please sign in to comment.