Summarization
Transformers
PyTorch
Safetensors
English
t5
text2text-generation
Trained with AutoTrain
text-generation-inference
Run this model with HF Jobs
Run sagard21/python-code-explainer on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/sagard21/python-code-explainer. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/sagard21/python-code-explainer on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use sagard21/python-code-explainer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sagard21/python-code-explainer with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "summarization" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("summarization", model="sagard21/python-code-explainer")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("sagard21/python-code-explainer") model = AutoModelForSeq2SeqLM.from_pretrained("sagard21/python-code-explainer", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files33 unmodified lines343536373839404142434433 unmodified lines# Model Usage```pyfrom transformers import AutoTokenizer, AutoModelForSeq2SeqLMtokenizer = AutoTokenizer.from_pretrained("sagard21/python-code-explainer")model = AutoModelForSeq2SeqLM.from_pretrained("sagard21/python-code-explainer")```33 unmodified lines34353637383940414243444546474849505152535455565758596061626364656667686933 unmodified lines# Model Usage```pyfrom transformers import (AutoModelForSeq2SeqLM,AutoTokenizer,AutoConfig,pipeline,)model_name = "sagard21/python-code-explainer"tokenizer = AutoTokenizer.from_pretrained(model_name, padding=True)model = AutoModelForSeq2SeqLM.from_pretrained(model_name)config = AutoConfig.from_pretrained(model_name)model.eval()pipe = pipeline("summarization", model=model_name, config=config, tokenizer=tokenizer)raw_code = """def preprocess(text: str) -> str:text = str(text)text = text.replace("\n", " ")tokenized_text = text.split(" ")preprocessed_text = " ".join([token for token in tokenized_text if token])return preprocessed_text"""print(pipe(raw_code)[0]["summary_text"])```
README.md+28-3