Skip to content

tests/test_pipeline.py::TestRAGPipeline::test_query - TypeError: TransformersModel.generate() got an unexpected keyword argument 'temperature' #7

@rkclimate20

Description

@rkclimate20

System Information: Windows 10, Virtual env with python 3.12

Output for pytest run with branch main of llmrag

.....FF...                                                                                                                                                [100%]
=========================================================================== FAILURES ===========================================================================
__________________________________________________________________ TestRAGPipeline.test_query __________________________________________________________________

self = <llmrag.tests.test_pipeline.TestRAGPipeline testMethod=test_query>

    def test_query(self):
        question = "What is photosynthesis?"
>       answer = self.pipeline.query(question)

tests\test_pipeline.py:40:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <llmrag.pipelines.rag_pipeline.RAGPipeline object at 0x000002BFD39D9340>, question = 'What is photosynthesis?', top_k = 4, temperature = 0.3

    def query(self, question: str, top_k=4, temperature=0.3) -> str:
        docs = self.vector_store.retrieve(question, top_k=top_k)

        # Deduplicate context to reduce redundancy
        seen = set()
        unique_docs = []
        for doc in docs:
            if doc.page_content not in seen:
                seen.add(doc.page_content)
                unique_docs.append(doc)

        context = "\n".join(doc.page_content for doc in unique_docs)

        # Clear instruction with delimiter to prevent multiple QA pairs
        prompt = f"""You are a helpful assistant. Use ONLY the following context to answer the user's question.
    If the answer is not in the context, say "I don't know."

    Context:
    {context}

    Question: {question}
    Answer:"""

>       return self.model.generate(prompt, temperature=temperature)
E       TypeError: TransformersModel.generate() got an unexpected keyword argument 'temperature'

llmrag\pipelines\rag_pipeline.py:49: TypeError
-------------------------------------------------------------------- Captured stderr setup ---------------------------------------------------------------------
Device set to use cpu
__________________________________________________________ TestRAGPipeline.test_retrieve_and_generate __________________________________________________________

self = <llmrag.tests.test_pipeline.TestRAGPipeline testMethod=test_retrieve_and_generate>

    def test_retrieve_and_generate(self):
        question = "What is AI?"
>       response = self.pipeline.query(question)

tests\test_pipeline.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <llmrag.pipelines.rag_pipeline.RAGPipeline object at 0x000002BFD39D9340>, question = 'What is AI?', top_k = 4, temperature = 0.3

    def query(self, question: str, top_k=4, temperature=0.3) -> str:
        docs = self.vector_store.retrieve(question, top_k=top_k)

        # Deduplicate context to reduce redundancy
        seen = set()
        unique_docs = []
        for doc in docs:
            if doc.page_content not in seen:
                seen.add(doc.page_content)
                unique_docs.append(doc)

        context = "\n".join(doc.page_content for doc in unique_docs)

        # Clear instruction with delimiter to prevent multiple QA pairs
        prompt = f"""You are a helpful assistant. Use ONLY the following context to answer the user's question.
    If the answer is not in the context, say "I don't know."

    Context:
    {context}

    Question: {question}
    Answer:"""

>       return self.model.generate(prompt, temperature=temperature)
E       TypeError: TransformersModel.generate() got an unexpected keyword argument 'temperature'

llmrag\pipelines\rag_pipeline.py:49: TypeError
=================================================================== short test summary info ====================================================================
FAILED tests/test_pipeline.py::TestRAGPipeline::test_query - TypeError: TransformersModel.generate() got an unexpected keyword argument 'temperature'
FAILED tests/test_pipeline.py::TestRAGPipeline::test_retrieve_and_generate - TypeError: TransformersModel.generate() got an unexpected keyword argument 'temperature'
2 failed, 8 passed in 64.88s (0:01:04)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions