Alexander27 commited on
Commit
d72579f
·
verified ·
1 Parent(s): eb5a875

Update README.md

Browse files

# Nano-Butterfly Model
Welcome to the `Alexander27/Nano-Butterfly` model card! This is a Causal Language Model trained using Hugging Face AutoTrain.
## 🚀 How to Use
You can easily run this model using the `transformers` library.

### 1. Installation

First, make sure you have the required libraries installed.

```bash
pip install transformers torch
```

### 2. Run the Model in Python

Save the following code as a Python file (e.g., `app.py`) and run it.

```python
from transformers import AutoTokenizer, AutoModelForCausalLM

# The name of your model on the Hugging Face Hub
model_name = "Alexander27/Nano-Butterfly"

# Load the tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

# Define the prompt
prompt = "The future of artificial intelligence is "

# Prepare the input for the model
input_ids = tokenizer.encode(prompt, return_tensors="pt")

# Generate text
output_sequences = model.generate(
input_ids=input_ids,
max_length=100,
num_return_sequences=1
)

# Decode the output and print it
generated_text = tokenizer.decode(output_sequences[0], skip_special_tokens=True)

print(generated_text)
```
Other code in python:
# File: app.py

# 1. Install necessary libraries
# In your terminal, run: pip install transformers torch

from transformers import AutoTokenizer, AutoModelForCausalLM

# The name of your model on the Hugging Face Hub
model_name = "Alexander27/Nano-Butterfly"

# 2. Load the tokenizer and model
print(f"Loading model: {model_name}")
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
print("Model loaded successfully!")

# 3. Define the prompt (the input text for the model)
prompt = "The future of artificial intelligence is "

# 4. Prepare the input for the model
input_ids = tokenizer.encode(prompt, return_tensors="pt")

# 5. Generate text
# max_length controls how long the output will be
output_sequences = model.generate(
input_ids=input_ids,
max_length=100,
num_return_sequences=1
)

# 6. Decode the output and print it
generated_text = tokenizer.decode(output_sequences[0], skip_special_tokens=True)

print("\n--- Model Output ---")
print(generated_text)

Files changed (1) hide show
  1. README.md +1 -1
README.md CHANGED
@@ -19,4 +19,4 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
19
 
20
  Contributing
21
 
22
- Contributions are welcome! Please fork the repository, make your changes, and submit a pull request. All contributions must follow the code style of the project.
 
19
 
20
  Contributing
21
 
22
+ Contributions are welcome! Please fork the repository, make your changes, and submit a pull request. All contributions must follow the code style of the project.