Spaces:
Running
Running
File size: 434 Bytes
f861dee |
1 2 3 4 5 6 7 8 9 10 11 |
from transformers import pipeline
class SemanticResponseGenerator:
def __init__(self):
self.generator = pipeline("text-generation", model="gpt2")
def generate_response(self, retrieved_docs):
combined_docs = " ".join(retrieved_docs[:2]) # Use top 2 matches
response = self.generator(f"Based on the following information: {combined_docs}", max_length=100)
return response[0]["generated_text"]
|