Edit model card

Model Card for Krakowiak-v2-7b

Krakowiak-v2-7b is a state of the art 7.3 billion parameters LLM based on Mistral-7B. It was finetuned for Polish text generation using custom created large corpus of 300K Polish instructions. It uses novel techniques e.g. LORA, adding noise to the embeddings for greater preformance. For full details of this model please read our paper to be released soon

Model Architecture

Krakowiak-v2-7b is a huge update to Krakowiak-7b bringing the following improvements:

  • Grouped-Query Attention
  • Sliding-Window Attention
  • Byte-fallback BPE tokenizer
  • Significantly larger training corpus of better quality
  • Improved training pipeline
  • Faster inference
  • No random token generation (generating Russian or Czech text alongside Polish)
  • Significantly higher quality of generated text

Krakowiak does not have any censorship mechanisms implemented.

Instruction format

In order to leverage instruction fine-tuning, your prompt should be surrounded by [INST] and [/INST] tokens. The very first instruction should begin with a begin of sentence id. The next instructions should not. The assistant generation will be ended by the end-of-sentence token id.

E.g.

text = "<s>[INST] Czy warto się uczyć? [/INST]"
"Jako model języka AI nie mam osobistych opinii ani przekonań. Jednak uczanie się jest ogólnie cenione i angażuje długoterminowe korzyści dla jednostki i społeczeństwa. Dzięki nauce można opracować umiejętności, zdobąć wiedzę i zwiększyć potencjał osobisty i zawodowy. Ponadto nauka promuje otwartość na innowacje i może zapewnić lepszą perspektywę życia. Dlatego uczanie się jest ogólnie cenione i wartościowe dla osób, które chcą osiągnąć cel lub rozwinąć swoją wiedzę. Jednak każda sytuacja może być inna i niektóre osoby mogą mieć różne cele lub okoliczności, które wpływają na ich podejście do nauki. Ostatecznie zależy to od indywidualnych preferencji i celów.</s> "
"[INST] Gdzie warto się uczyć? [/INST]"

Model parameters

From my experience the temperature value of 0.7 is the best baseline value.

Optimal text generation

from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
import torch
torch_device = "cuda" if torch.cuda.is_available() else "cpu"

chat_tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1")
messages = [
    {"role": "user", "content": "Czy warto nauczyć się jeździć na nartach w wieku 25 lat?"},
]
chat_tokenized = tokenizer.apply_chat_template(messages, tokenize=False)

model = AutoModelForCausalLM.from_pretrained("szymonrucinski/Krakowiak-7B-v2")
model.config.pad_token_id = model.config.eos_token_id

tokenizer = AutoTokenizer.from_pretrained("szymonrucinski/Krakowiak-7B-v2",add_eos_token=True)
tokenizer.pad_token = tokenizer.eos_token
model_inputs = tokenizer(chat_tokenized, return_tensors='pt').to(torch_device)

beam_outputs = model.generate(
    **model_inputs,
    max_new_tokens=1024,
    num_beams=5,
    no_repeat_ngram_size=2,
    num_return_sequences=1,
    early_stopping=True
)
print(tokenizer.decode(beam_outputs[0], skip_special_tokens=True))

Use a pipeline as a high-level helper

from transformers import pipeline

pipe = pipeline("text-generation", model="szymonrucinski/krakowiak-v2-7b")

pipe("<s>[INST] Też lubisz jeździć na rowerze? [/INST]")

Demo

You can play with Krakowiak-v2-7b here. This model uses 4-bit quantization technique and CPU inference that negatively influence the quality of the output but are more cost effective. You can run Krakowiak on your CPU using its quantized version availabe here

Krakowiak team

Szymon Franciszek Ruciński

Citation

If you find the content of this repo useful in your work, please cite it as follows:

@misc{Krakowiak-V2-7B,
  author = {Szymon Ruciński},
  title = {Krakowiak-V2-7B},
  year = {2023},
  publisher = {Huggingface},
  journal = {Huggingface repository},
  howpublished = {\url{https://huggingface.co/szymonrucinski/krakowiak-v2-7b/}}
}
Downloads last month
56
Safetensors
Model size
7.24B params
Tensor type
FP16
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Collection including szymonrucinski/Krakowiak-7B-v2