mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-07-27 10:49:52 +00:00

* Files moved, imports all broken * Fix most imports and docstrings into * Fix the paths to the modules in the API docs * Add latest docstring and tutorial changes * Add a few pipelines that were lost in the inports * Fix a bunch of mypy warnings * Add latest docstring and tutorial changes * Create a file_classifier module * Add docs for file_classifier * Fixed most circular imports, now the REST API can start * Add latest docstring and tutorial changes * Tackling more mypy issues * Reintroduce from FARM and fix last mypy issues hopefully * Re-enable old-style imports * Fix some more import from the top-level package in an attempt to sort out circular imports * Fix some imports in tests to new-style to prevent failed class equalities from breaking tests * Change document_store into document_stores * Update imports in tutorials * Add latest docstring and tutorial changes * Probably fixes summarizer tests * Improve the old-style import allowing module imports (should work) * Try to fix the docs * Remove dedicated KnowledgeGraph page from autodocs * Remove dedicated GraphRetriever page from autodocs * Fix generate_docstrings.sh with an updated list of yaml files to look for * Fix some more modules in the docs * Fix the document stores docs too * Fix a small issue on Tutorial14 * Add latest docstring and tutorial changes * Add deprecation warning to old-style imports * Remove stray folder and import Dict into dense.py * Change import path for MLFlowLogger * Add old loggers path to the import path aliases * Fix debug output of convert_ipynb.py * Fix circular import on BaseRetriever * Missed one merge block * re-run tutorial 5 * Fix imports in tutorial 5 * Re-enable squad_to_dpr CLI from the root package and move get_batches_from_generator into document_stores.base * Add latest docstring and tutorial changes * Fix typo in utils __init__ * Fix a few more imports * Fix benchmarks too * New-style imports in test_knowledge_graph * Rollback setup.py * Rollback squad_to_dpr too Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
39 lines
2.6 KiB
Python
39 lines
2.6 KiB
Python
from haystack.pipeline import QuestionAnswerGenerationPipeline, QuestionGenerationPipeline, RetrieverQuestionGenerationPipeline
|
||
from haystack.schema import Document
|
||
import pytest
|
||
|
||
|
||
text = 'The Living End are an Australian punk rockabilly band from Melbourne, formed in 1994. Since 2002, the line-up consists of Chris Cheney (vocals, guitar), Scott Owen (double bass, vocals), and Andy Strachan (drums). The band rose to fame in 1997 after the release of their EP Second Solution / Prisoner of Society, which peaked at No. 4 on the Australian ARIA Singles Chart. They have released eight studio albums, two of which reached the No. 1 spot on the ARIA Albums Chart: The Living End (October 1998) and State of Emergency (February 2006). They have also achieved chart success in the U.S. and the United Kingdom. The Band was nominated 27 times and won five awards at the Australian ARIA Music Awards ceremonies: "Highest Selling Single" for Second Solution / Prisoner of Society (1998), "Breakthrough Artist – Album" and "Best Group" for The Living End (1999), as well as "Best Rock Album" for White Noise (2008) and The Ending Is Just the Beginning Repeating (2011). In October 2010, their debut album was listed in the book "100 Best Australian Albums". Australian musicologist Ian McFarlane described the group as "one of Australia’s premier rock acts. By blending a range of styles (punk, rockabilly and flat out rock) with great success, The Living End has managed to produce anthemic choruses and memorable songs in abundance".'
|
||
document = Document(content=text)
|
||
query = "Living End"
|
||
|
||
|
||
def test_qg_pipeline(question_generator):
|
||
p = QuestionGenerationPipeline(question_generator)
|
||
result = p.run(documents=[document])
|
||
keys = list(result)
|
||
assert "generated_questions" in keys
|
||
assert len(result["generated_questions"][0]["questions"]) > 0
|
||
|
||
|
||
@pytest.mark.parametrize("retriever,document_store", [("tfidf", "memory")], indirect=True)
|
||
def test_rqg_pipeline(question_generator, retriever):
|
||
retriever.document_store.write_documents([document])
|
||
retriever.fit()
|
||
p = RetrieverQuestionGenerationPipeline(retriever, question_generator)
|
||
result = p.run(query)
|
||
keys = list(result)
|
||
assert "generated_questions" in keys
|
||
assert len(result["generated_questions"][0]["questions"]) > 0
|
||
|
||
|
||
@pytest.mark.parametrize("reader", ["farm"], indirect=True)
|
||
def test_qag_pipeline(question_generator, reader):
|
||
p = QuestionAnswerGenerationPipeline(question_generator, reader)
|
||
results = p.run(documents=[document])["results"]
|
||
assert len(results) > 0
|
||
assert results[0]["query"]
|
||
assert len(results[0]["answers"]) > 0
|
||
assert results[0]["answers"][0].answer is not None
|
||
|