| tags: | |
| - matformer | |
| - custom-model | |
| library_name: transformers | |
| # Matformer Model | |
| Trained using [Matformer](https://github.com/mrinaldi97/matformer). | |
| ## Installation | |
| ```bash | |
| pip install git+https://github.com/mrinaldi97/matformer.git | |
| ``` | |
| ## Usage | |
| ```python | |
| import torch | |
| from transformers import AutoModelForCausalLM | |
| model = AutoModelForCausalLM.from_pretrained( | |
| "mrinaldi/prova001", | |
| trust_remote_code=True | |
| ) | |
| prompt = "The transformer model is a" | |
| inputs = model.matformer_model.tokenizer.encode(prompt, add_bos=True, add_eos=False) | |
| inputs = torch.tensor([inputs], device="cuda") | |
| with torch.no_grad(): | |
| outputs = model.generate(inputs, max_new_tokens=50) | |
| decoded = model.matformer_model.tokenizer.decode(outputs[0].tolist()) | |
| print(decoded) | |
| ``` | |