Spaces:
Runtime error
Runtime error
import nbformat as nbf | |
def create_hf_card(cells, name, base_model_name, base_model_version, dataset_name, output_dir, report_to): | |
text = f""" | |
card = ''' | |
--- | |
license: apache-2.0 | |
tags: | |
- generated_from_trainer | |
- {base_model_name} | |
- PyTorch | |
- transformers | |
- trl | |
- peft | |
- {report_to} | |
base_model: {base_model_name}-{base_model_version} | |
widget: | |
- example_title: Pirate! | |
messages: | |
- role: system | |
content: You are a pirate chatbot who always responds with Arr! | |
- role: user | |
content: "There's a llama on my lawn, how can I get rid of him?" | |
output: | |
text: >- | |
Arr! 'Tis a puzzlin' matter, me hearty! A llama on yer lawn be a rare | |
sight, but I've got a plan that might help ye get rid of 'im. Ye'll need | |
to gather some carrots and hay, and then lure the llama away with the | |
promise of a tasty treat. Once he's gone, ye can clean up yer lawn and | |
enjoy the peace and quiet once again. But beware, me hearty, for there | |
may be more llamas where that one came from! Arr! | |
model-index: | |
- name: {name} | |
results: [] | |
datasets: | |
- {dataset_name} | |
language: | |
- en | |
pipeline_tag: text-generation | |
--- | |
# Model Card for {name}: | |
**{name}** is a language model that is trained to act as helpful assistant. It is a finetuned version of [{base_model_name}-{base_model_version}](https://huggingface.co/{base_model_name}-{base_model_version}) that was trained using `SFTTrainer` on publicly available dataset [ | |
{dataset_name}](https://huggingface.co/datasets/{dataset_name}). | |
## Training Procedure: | |
The training code used to create this model was generated by [Menouar/LLM-FineTuning-Notebook-Generator](https://huggingface.co/spaces/Menouar/LLM-FineTuning-Notebook-Generator). | |
## Training hyperparameters | |
The following hyperparameters were used during the training: | |
''' | |
with open("{output_dir}/README.md", "w") as f: | |
f.write(card) | |
args_dict = vars(args) | |
with open("{output_dir}/README.md", "a") as f: | |
for k, v in args_dict.items(): | |
f.write(f"- {{k}}: {{v}}") | |
f.write("\\n \\n") | |
""" | |
title = """### Generating a model card (README.md)""" | |
cells.append(nbf.v4.new_markdown_cell(title)) | |
code_cell = nbf.v4.new_code_cell(text) | |
cells.append(code_cell) | |