Instructions to use szymonrucinski/Krakowiak-7B-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use szymonrucinski/Krakowiak-7B-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="szymonrucinski/Krakowiak-7B-v2")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("szymonrucinski/Krakowiak-7B-v2") model = AutoModelForMultimodalLM.from_pretrained("szymonrucinski/Krakowiak-7B-v2") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use szymonrucinski/Krakowiak-7B-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "szymonrucinski/Krakowiak-7B-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "szymonrucinski/Krakowiak-7B-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/szymonrucinski/Krakowiak-7B-v2
- SGLang
How to use szymonrucinski/Krakowiak-7B-v2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "szymonrucinski/Krakowiak-7B-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "szymonrucinski/Krakowiak-7B-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "szymonrucinski/Krakowiak-7B-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "szymonrucinski/Krakowiak-7B-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use szymonrucinski/Krakowiak-7B-v2 with Docker Model Runner:
docker model run hf.co/szymonrucinski/Krakowiak-7B-v2
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
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
- 5