metharme-13b / README.md
11b's picture
docs: add notes about BOS and LoRA
5b10150
metadata
language:
  - en
thumbnail: null
tags:
  - text generation
  - instruct
pipeline_tag: text-generation
inference: false

Metharme 13B

An instruction-tuned LLaMA biased towards fiction writing and conversation.

Model Details

Metharme 13B is an instruct model based on Meta's LLaMA-13B.

This is an experiment to try and get a model that is usable for conversation, roleplaying and storywriting, but which can be guided using natural language like other instruct models. See the prompting section below for examples.

It was trained by doing supervised fine-tuning over a mixture of regular instruction data alongside roleplay, fictional stories and conversations with synthetically generated instructions attached.

Applying the XORs

The model weights in this repository cannot be used as-is. The files here are XORs due to licensing concerns. To obtain proper, usable model weights you need to:

  • Request access to the original LLaMA weights from Meta through this form

  • Convert them to the HuggingFace Transformers format by using the convert_llama_weights_to_hf.py script for your version of the transformers library

  • With the LLaMA-13B weights in hand, you can use the xor_codec.py script provided in this repository:

    python3 xor_codec.py \
      ./metharme-13b \
      ./xor_encoded_files \
      /path/to/hf-converted/llama-13b \
      --decode
    

For reference, these are the hashes you should get after following the steps above:

$ rhash --sha256 *
be2c276865d1b0759257c0934275f05e02ee520657c2d8ebe3f2a2db1562949a  config.json
a23652fc622a27b8863c39f524707796967095b2a85f334561b11422f71445a2  generation_config.json
78caa8fd29e4bf2fafcec71ba2b48afcb9516b7d1a43ce20cd0c511c620a42a2  pytorch_model-00001-of-00003.bin
7cef1f81c0f0bf130b331c4c9c26955da3913d62f141117e85fd5882d6cdf0d0  pytorch_model-00002-of-00003.bin
1059a1efade70d4a1a9f66176631f0dae239c50dd5c89d62deb873b3d4ea49a1  pytorch_model-00003-of-00003.bin
72e91e29282dae48ea5562fcf4d6ca0d5a9c2a30ebc8d67174a19e192552a20b  pytorch_model.bin.index.json
f9ffc4aede0845ab65324ce5dccb823dca2427f9a0710981e5bc2398d73d8162  tokenizer.json
9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347  tokenizer.model
bd87e244d21d45c358e5d822aeb2efd4e4d60127e43b648ed3efe7823fd35060  tokenizer_config.json

Prompting

The current model version has been trained on prompts using three different roles, which are denoted by the following tokens: <|system|>, <|user|> and <|model|>.

The <|system|> prompt can be used to inject out-of-channel information behind the scenes, while the <|user|> prompt should be used to indicate user input. The <|model|> token should then be used to indicate that the model should generate a response. These tokens can happen multiple times and be chained up to form a conversation history.

Prompting example

Here's a concrete example. Let's say you have the following system prompt:

This is a text adventure game. Describe the scenario to the user and give him three options to pick from on each turn.

And the user has typed in the following message:

Start!

To perform inference against the model, the prompt should be formatted like this:

<|system|>This is a text adventure game. Describe the scenario to the user and give him three options to pick from on each turn.<|user|>Start!<|model|>

The model might generate something like:

You are standing in front of an old, abandoned house. The windows are boarded up, and there's no sign of life around it. As you approach, you notice a strange feeling emanating from within. Suddenly, you hear a voice calling out to you... 'Come inside!'

  • Go inside the house.
  • Ignore the call and move away.
  • Run as fast as you can.

It will automatically emit an end-of-text token (</s>) when it judges that the response is complete.

Pretend then that the user has replied with go inside. The next prompt should then be:

<|system|>This is a text adventure game. Describe the scenario to the user and give him three options to pick from on each turn.<|user|>Start!<|model|>You are standing in front of an old, abandoned house. The windows are boarded up, and there's no sign of life around it. As you approach, you notice a strange feeling emanating from within. Suddenly, you hear a voice calling out to you... 'Come inside!'

- Go inside the house.
- Ignore the call and move away.
- Run as fast as you can.<|user|>go inside<|model|>

Which might generate something like:

You enter the house, and immediately, a wave of unsettling energy washes over you. Your senses seem heightened, but your mind feels foggy. A figure appears before you - a tall man with piercing eyes. He speaks to you in a language you don't understand.

  • Ask him what he wants.
  • Attack him.
  • Run away.

Same process applies. Usually, it is best to do a sliding window over the user and model turns, but keep the system prompt fixed at the start of the context window.

Other notes

  • When prompted correctly, the model will always start by generating a BOS token. This behavior is an accidental side-effect which we plan to address in future model versions and should not be relied upon.
  • The model was trained as a LoRA with a somewhat unorthodox configuration which causes errors when used with the current version of peft, hence we release it as a full model instead.

Limitations and biases

The intended use-case for this model is fictional writing for entertainment purposes. Any other sort of usage is out of scope.

As such, it was not fine-tuned to be safe and harmless: the base model and this fine-tune have been trained on data known to contain profanity and texts that are lewd or otherwise offensive. It may produce socially unacceptable or undesirable text, even if the prompt itself does not include anything explicitly offensive. Outputs might often be factually wrong or misleading.