File size: 1,747 Bytes
633ef02 efd03f1 633ef02 a0fac8a 633ef02 efd03f1 633ef02 efd03f1 47a7c06 efd03f1 47a7c06 efd03f1 47a7c06 efd03f1 633ef02 |
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
---
tags:
- autotrain
- summarization
language:
- en
widget:
- text: >
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
datasets:
- sagard21/autotrain-data-code-explainer
co2_eq_emissions:
emissions: 5.393079045128973
license: mit
pipeline_tag: summarization
---
# Model Trained Using AutoTrain
- Problem type: Summarization
- Model ID: 2745581349
- CO2 Emissions (in grams): 5.3931
# Model Description
This model is an attempt to simplify code understanding by generating line by line explanation of a source code. This model was fine-tuned using the Salesforce/codet5-large model. Currently it is trained on a small subset of Python snippets.
# Model Usage
```py
from 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"])
```
## Validation Metrics
- Loss: 2.156
- Rouge1: 29.375
- Rouge2: 18.128
- RougeL: 25.445
- RougeLsum: 28.084
- Gen Len: 19.000
|