Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions gpt-oss-main/run_transformers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from transformers import pipeline

try:
model_id = "openai/gpt-oss-20b"
pipe = pipeline("text-generation", model=model_id, torch_dtype="auto", device_map="auto")
except Exception as e:
print("⚠️ Could not load gpt-oss-20b, falling back to gpt2.")
print("Error:", e)
model_id = "gpt2"
pipe = pipeline("text-generation", model=model_id)

messages = [{"role": "user", "content": "Explain quantum mechanics clearly and concisely."}]
outputs = pipe(messages, max_new_tokens=100)
Comment on lines +12 to +13

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pass a string prompt to the text-generation pipeline

The script calls pipeline("text-generation") with messages defined as a list of role/content dictionaries and passes that list directly to pipe(...). The text-generation pipeline in Transformers expects a single prompt string (or list of strings), so this will raise a TypeError/ValueError before any generation occurs, both for the intended openai/gpt-oss-20b model and for the gpt2 fallback. Converting the message to a textual prompt (or using a chat-capable pipeline) is required for the script to run.

Useful? React with 👍 / 👎.

print(outputs[0]["generated_text"])
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.