diff --git a/pyproject.toml b/pyproject.toml index ae3071d..2bd338f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ authors = ["Owen Colegrove "] license = "Apache-2.0" readme = "README.md" name = 'sciphi-synthesizer' -version = '1.0.2' +version = '1.0.3' packages = [ { include = "synthesizer" } ] diff --git a/synthesizer/interface/llm/sciphi_interface.py b/synthesizer/interface/llm/sciphi_interface.py index d529236..776e79f 100644 --- a/synthesizer/interface/llm/sciphi_interface.py +++ b/synthesizer/interface/llm/sciphi_interface.py @@ -13,7 +13,6 @@ class SciPhiLLMInterface(LLMInterface): """A class to interface with the SciPhi API.""" provider_name = LLMProviderName.SCIPHI - system_message = "You are a helpful assistant." def __init__( self, @@ -32,21 +31,9 @@ def get_completion( logger.debug( f"Getting completion from SciPhi API for model={generation_config.model_name}" ) - if "instruct" in generation_config.model_name: - return self.model.get_instruct_completion( - prompt, generation_config - ) - else: - return self._model.get_chat_completion( - [ - { - "role": "system", - "content": SciPhiLLMInterface.system_message, - }, - {"role": "user", "content": prompt}, - ], - generation_config, - ) + return self.model.get_instruct_completion( + prompt, generation_config + ) def get_chat_completion( self, conversation: list[dict], generation_config: GenerationConfig diff --git a/synthesizer/llm/config_manager.py b/synthesizer/llm/config_manager.py index 031acb0..cff0c00 100644 --- a/synthesizer/llm/config_manager.py +++ b/synthesizer/llm/config_manager.py @@ -15,10 +15,6 @@ def get_config_for_provider( llm_provider_name: LLMProviderName, ) -> Type[LLMConfig]: """Get the configuration class for a given model.""" - print( - "LLMConfigManager.config_registry = ", - LLMConfigManager.config_registry, - ) config_class = LLMConfigManager.config_registry.get(llm_provider_name) if not config_class: diff --git a/synthesizer/scripts/run_rag.py b/synthesizer/scripts/run_rag.py index 861c113..0089a3d 100644 --- a/synthesizer/scripts/run_rag.py +++ b/synthesizer/scripts/run_rag.py @@ -1,3 +1,4 @@ +import json from synthesizer.core import LLMProviderName, RAGProviderName from synthesizer.interface import ( LLMInterfaceManager, @@ -6,27 +7,20 @@ from synthesizer.llm import GenerationConfig import fire -# Note, it is understood that the prompt has an issue with redundancy. This will be addressed shortly. PROMPT = """ ### Instruction: -### Instruction: - -Prompt: +Query: {query} -Context: +Search Results: {rag_context} -Prompt: +Query: {query} -Your task is to write a response to the given prompt. If the prompt is clearly a question, then answer it directly. If the prompt is a statement, then the most important related context that you have been given. WRITE THREE DISTINCT SECTIONS `### My Work`, `### My Answer`, and `### My Further Considerations` as shown below. ONLY USE THE PROVIDED CONTEXT to answer the question, and if the context is insufficient then answer with \"Insufficient Context\". Be sure to include at least 5 distinct sources in your final answer.\n\n### My Work\n- **Valid Premise Check:** Ensure that the question contains a valid premise before answering.\n- **Contextual Analysis:** Think step-by-step about the provided context to identify the most important and/or relevant themes covered in the provided information. Be sure to consider at least 5 distinct sources.\n\n### My Answer\n- **Answer with Inline Numbered Citations:** Provide a response in two to three paragraphs, including inline citations to the most relevant evidence from the provided context. Use the following format for inline citations: `[1]`, `[2]`, `[3]`, etc.\n\n### My Further Considerations\n- **Implications and Follow-Ups:** Consider the implications of the question and answer. Identify any related follow-up questions or considerations that come to mind. \n- **Queries** Provide a comma-separated list of Google queries that you would like to see answered in the future.\n\nBegin your work now:\n \n - -### Response: - ### Response: - +{{"summary": """ @@ -44,20 +38,15 @@ def __init__(self): def run( self, query="What is a quantum field theory in curved space time?", - # rag_prompt="### Instruction:\nYour task is to use the context which follows to answer the question with a two paragraph line-item cited response:\n{rag_context}\nBegin your two paragraph answer with line-item citations now:### Response:\n", - # rag parameters rag_provider_name="agent-search", rag_api_base="https://api.sciphi.ai", - rag_limit_hierarchical_url_results="50", - rag_limit_final_pagerank_results="20", # llm parameters llm_provider_name="sciphi", - llm_model_name="SciPhi/SciPhi-SearchAgent-Alpha-7B", + llm_model_name="SciPhi/Sensei-7B-V1", llm_max_tokens_to_sample=1_024, llm_temperature=0.1, llm_top_p=0.95, ): - # RAG Provider Settings rag_interface = RAGInterfaceManager.get_interface_from_args( RAGProviderName(rag_provider_name), @@ -81,15 +70,13 @@ def run( ) formatted_prompt = PROMPT.format(rag_context=rag_context, query=query) - completion = llm_interface.get_completion( + completion = '{"summary":' + llm_interface.get_completion( formatted_prompt, generation_config - ) - print(completion) + ).replace("", "") + print(json.loads(completion)) ### Output: - # Fermat's Last Theorem was proven by British mathematician Andrew Wiles in 1994 (Wikipedia). Wiles's proof was based on a special case of the modularity theorem for elliptic curves, along with Ribet's theorem (Wikipedia). The modularity theorem and Fermat's Last Theorem were previously considered inaccessible to proof by contemporaneous mathematicians (Wikipedia). However, Wiles's proof provided a solution to Fermat's Last Theorem, which had remained unproved for over 300 years (PlanetMath). Wiles's proof is widely accepted and has been recognized with numerous awards, including the Abel Prize in 2016 (Wikipedia). - - # It is important to note that Wiles's proof of Fermat's Last Theorem is a mathematical proof and not related to the science fiction novel "The Last Theorem" by Arthur C. Clarke and Frederik Pohl (Wikipedia). The novel is a work of fiction and does not provide a real mathematical proof for Fermat's Last Theorem (Wikipedia). Additionally, there have been other attempts to prove Fermat's Last Theorem, such as Sophie Germain's approach, but Wiles's proof is the most widely accepted and recognized (Math Stack Exchange). + # {"summary": "\nFermat's Last Theorem is a significant result in number theory, stating that for any natural number n greater than 2, there are no solutions to the equation \\(a^n + b^n = c^n\\) where \\(a\\), \\(b\\), and \\(c\\) are positive integers [5]. The theorem was first proposed by Pierre de Fermat in the margins of his copy of Diophantus's \"Arithmetica\" in the 17th century, but it remained unproved for over three centuries [8]. The first case of the theorem to be proven was by Fermat himself for \\(n = 4\\), using a method of infinite descent [9]. Leonhard Euler later provided a proof for the case \\(n = 3\\), although his initial proof contained errors that were later corrected [9].\n\nThe theorem was finally proven in its entirety in 1995 by British mathematician Andrew Wiles, using sophisticated mathematical tools and techniques that were not available during Fermat's lifetime [10]. This breakthrough marked the end of a long period of mathematical speculation and the resolution of a major historical puzzle in mathematics [10]. The proof of Fermat's Last Theorem has been hailed as one of the most significant achievements in the history of mathematics, demonstrating the power of modern mathematical methods and the persistence of mathematical inquiry over centuries [10].\n\n", "other_queries": ["Details of Fermat's Last Theorem proof", "Historical impact of Fermat's Last Theorem", "Contributions of Andrew Wiles to mathematics", "Techniques used in the proof of Fermat's Last Theorem", "Evolution of number theory post-Fermat's Last Theorem"]} if __name__ == "__main__":