--- inference: false language: en license: llama2 model_type: llama datasets: - mlabonne/CodeLlama-2-20k pipeline_tag: text-generation tags: - llama-2 --- # CRIA v1.3 💡 [Article](https://walterteng.com/cria) | 💻 [Github](https://github.com/davzoku/cria) | 📔 Colab [1](https://colab.research.google.com/drive/1rYTs3qWJerrYwihf1j0f00cnzzcpAfYe),[2](https://colab.research.google.com/drive/1Wjs2I1VHjs6zT_GE42iEXsLtYh6VqiJU) ## What is CRIA? > krē-ə plural crias. : a baby llama, alpaca, vicuña, or guanaco.

Cria Logo
or what ChatGPT suggests, "Crafting a Rapid prototype of an Intelligent llm App using open source resources".

The initial objective of the CRIA project is to develop a comprehensive end-to-end chatbot system, starting from the instruction-tuning of a large language model and extending to its deployment on the web using frameworks such as Next.js. Specifically, we have fine-tuned the `llama-2-7b-chat-hf` model with QLoRA (4-bit precision) using the [mlabonne/CodeLlama-2-20k](https://huggingface.co/datasets/mlabonne/CodeLlama-2-20k) dataset. This fine-tuned model serves as the backbone for the [CRIA chat](https://chat.walterteng.com) platform. ## 📦 Model Release CRIA v1.3 comes with several variants. - [davzoku/cria-llama2-7b-v1.3](https://huggingface.co/davzoku/cria-llama2-7b-v1.3): Merged Model - [davzoku/cria-llama2-7b-v1.3-GGML](https://huggingface.co/davzoku/cria-llama2-7b-v1.3-GGML): Quantized Merged Model - [davzoku/cria-llama2-7b-v1.3_peft](https://huggingface.co/davzoku/cria-llama2-7b-v1.3_peft): PEFT adapter - [davzoku/cria-llama2-7b-v1.3-GGUF](https://huggingface.co/davzoku/cria-llama2-7b-v1.3-GGUF): GGUF Format - converted from ggml vq4_0 using `python3 convert-llama-ggml-to-gguf.py -i ../text-generation-webui/models/cria/cria-llama2-7b-v1.3.ggmlv3.q4_0.bin -o cria-llama2-7b-v1.3.gguf` - [davzoku/cria-llama2-7b-v1.3-mlx](https://huggingface.co/davzoku/cria-llama2-7b-v1.3-mlx): MLX Format in FP16 - Converted from [davzoku/cria-llama2-7b-v1.3](https://huggingface.co/davzoku/cria-llama2-7b-v1.3) using [mlx-examples](https://github.com/davzoku/mlx-examples). see [NOTES.md](https://github.com/davzoku/mlx-examples/blob/cria/notes/NOTES.md) - [davzoku/cria-llama2-7b-v1.3-q4-mlx](https://huggingface.co/davzoku/cria-llama2-7b-v1.3-q4-mlx): MLX Format in Q4 - Converted from [davzoku/cria-llama2-7b-v1.3](https://huggingface.co/davzoku/cria-llama2-7b-v1.3) using [mlx-examples](https://github.com/davzoku/mlx-examples). see [NOTES.md](https://github.com/davzoku/mlx-examples/blob/cria/notes/NOTES.md) ## 🔧 Training It was trained on a Google Colab notebook with a T4 GPU and high RAM. ### Training procedure The following `bitsandbytes` quantization config was used during training: - load_in_8bit: False - load_in_4bit: True - llm_int8_threshold: 6.0 - llm_int8_skip_modules: None - llm_int8_enable_fp32_cpu_offload: False - llm_int8_has_fp16_weight: False - bnb_4bit_quant_type: nf4 - bnb_4bit_use_double_quant: False - bnb_4bit_compute_dtype: float16 ### Framework versions - PEFT 0.4.0 ## 💻 Usage This model was converted to MLX format from [davzoku/cria-llama2-7b-v1.3](https://huggingface.co/davzoku/cria-llama2-7b-v1.3). ### Use with mlx ```bash pip install mlx-lm ``` ```python from mlx_lm import load, generate model, tokenizer = load("davzoku/cria-llama2-7b-v1.3-mlx") response = generate(model, tokenizer, prompt="hello", verbose=True) ``` ### Original Usage ```python # pip install transformers accelerate from transformers import AutoTokenizer import transformers import torch model = "davzoku/cria-llama2-7b-v1.3" prompt = "What is a cria?" tokenizer = AutoTokenizer.from_pretrained(model) pipeline = transformers.pipeline( "text-generation", model=model, torch_dtype=torch.float16, device_map="auto", ) sequences = pipeline( f'[INST] {prompt} [/INST]', do_sample=True, top_k=10, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id, max_length=200, ) for seq in sequences: print(f"Result: {seq['generated_text']}") ``` ## References We'd like to thank: - [mlabonne](https://huggingface.co/mlabonne) for his article and resources on implementation of instruction tuning - [TheBloke](https://huggingface.co/TheBloke) for his script for LLM quantization.