Spaces:
Sleeping
Sleeping
File size: 1,006 Bytes
34da888 bcdb714 34da888 7787d4b 34da888 bcdb714 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "IlmaJiyadh/phi3-4k-ft"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
trust_remote_code=True
)
def summarize(text):
prompt = f"Below is a lecture transcript. Take lecture notes in bullet points.\n\nInput:\n{text}\n\nSummary:\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=200, temperature=0.7, use_cache=False)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
gr.Interface(
fn=summarize,
inputs=gr.Textbox(lines=10, label="π Paste Transcript"),
outputs=gr.Textbox(label="π Summary"),
title="π§ Transcript β Summary (Phi-3 Fine-tuned)",
description="Test only the summarization step."
).launch()
|