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 lines3435363738394041424344454647484950515253545556575859606162636465666733 unmodified lines# Model Usage```pyfrom transformers import AutoTokenizer, T5ForConditionalGeneration, SummarizationPipelinepipeline = SummarizationPipeline(model=T5ForConditionalGeneration.from_pretrained("sagard21/python-code-explainer"),tokenizer=AutoTokenizer.from_pretrained("sagard21/python-code-explainer", skip_special_tokens=True),)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"""pipeline([raw_code])```### Expected JSON Output```[{"summary_text": "Create a function preprocess that will take the text as an argument and return the preprocessed text.\n1. In this case, the text will be converted to a string.\n2. At first, we will replace all \"\\n\" with \" \" and then split the text by \" \".\n3. Then we will call the tokenize function on the text and tokenize the text using the split() method.\n4. Next step is to create a list of all the tokens in the string and join them together.\n5. Then the function will return the string preprocessed_text.\n"}]```## Validation Metrics33 unmodified lines34353637383940414243444533 unmodified lines# Model Usage```pyfrom transformers import AutoTokenizer, AutoModelForSeq2SeqLMtokenizer = AutoTokenizer.from_pretrained("sagard21/python-code-explainer")model = AutoModelForSeq2SeqLM.from_pretrained("sagard21/python-code-explainer")```## Validation Metrics
README.md+3-25