Edit model card

Model Inference

from transformers import T5ForConditionalGeneration, T5Tokenizer

model = T5ForConditionalGeneration.from_pretrained("Mr-Vicky-01/context-qa-2")
tokenizer = T5Tokenizer.from_pretrained("Mr-Vicky-01/context-qa-2")


def get_answer(question, prev_qa, context):
    input_text = [f"q: {qa[0]} a: {qa[1]}" for qa in prev_qa]
    input_text.append(f"q: {question}")
    input_text.append(f"c: {context}")
    input_text = " ".join(input_text)
    features = tokenizer([input_text], return_tensors='pt')
    tokens = model.generate(input_ids=features['input_ids'],
            attention_mask=features['attention_mask'], max_length=64)
    return tokenizer.decode(tokens[0], skip_special_tokens=True)

context = """
The global push for renewable energy has gained significant momentum in recent months, driven by rising concerns over climate change and the need for sustainable energy solutions. Countries around the world are setting ambitious targets to reduce greenhouse gas emissions, with many committing to achieving net-zero emissions by mid-century. For instance, the European Union has unveiled plans to cut emissions by at least 55% by 2030 compared to 1990 levels. Meanwhile, the United States is investing heavily in clean energy technologies, including wind, solar, and electric vehicles, as part of its broader climate strategy. Recent reports highlight that global investment in renewable energy reached a record high in 2023, surpassing $500 billion. This surge in funding is expected to accelerate the development of innovative technologies and infrastructure that will facilitate the transition to greener energy sources. However, challenges remain, including supply chain disruptions, regulatory hurdles, and the need for skilled labor to support this rapidly growing industry. As nations work towards their climate goals, the role of public policy and international cooperation will be critical in shaping a sustainable energy future.
"""

print(get_answer("that makes sense! What specific goals are countries setting to address these concerns?", [("What has driven the global push for renewable energy?", "rising concerns over climate change")], context))
Downloads last month
42
Safetensors
Model size
248M params
Tensor type
F32
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.