File size: 3,961 Bytes
f7adfa2 3eba8eb f7adfa2 3eba8eb f7adfa2 3eba8eb f7adfa2 3eba8eb f7adfa2 47267f5 f7adfa2 47267f5 f7adfa2 3b2c272 f7adfa2 47267f5 f7adfa2 3eba8eb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
---
license: other
---
# Llama-3.1-8B-Instruct-FastDraft-150M-int8-ov
## Description
FastDraft is a novel and efficient approach for pre-training and aligning a draft model to any LLM to be used with speculative decoding, by incorporating efficient pre-training followed by fine-tuning over synthetic datasets generated by the target model.
FastDraft was presented in the [paper](https://arxiv.org/abs/2411.11055) at ENLSP@NeurIPS24 by Intel Labs.
This is a draft model that was trained with FastDraft to accompany [Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct).
This is Llama-3.1-8B-Instruct-FastDraft-150M model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2024/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to int8 by [NNCF](https://github.com/openvinotoolkit/nncf).
## Quantization Parameters
Weight compression was performed using `nncf.compress_weights` with the following parameters:
* mode: **INT8_ASYM**
For more information on quantization, check the [OpenVINO model optimization guide](https://docs.openvino.ai/2024/openvino-workflow/model-optimization-guide/weight-compression.html).
## Compatibility
The provided OpenVINO™ IR model is compatible with:
* OpenVINO version **2024.4** and higher
* Optimum Intel **1.20.0** and higher
## Running Model Inference with OpenVINO GenAI
1. Install packages required for using [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai) with Speculative decoding:
```
pip install openvino-genai huggingface_hub
```
2. Download and convert main model and tokenizer
Note: run model with demo, you will need to accept license agreement.
You must be a registered user in 🤗 Hugging Face Hub. Please visit [HuggingFace model card](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct),
carefully read terms of usage and click accept button. You will need to use an access token for the code below to run. For more information
on access tokens, refer to [this section of the documentation](https://huggingface.co/docs/hub/security-tokens).
```bash
pip install optimum-intel[openvino]
optimum-cli export openvino --model meta-llama/Meta-Llama-3.1-8B-Instruct --task text-generation-with-past --weight-format int8 main_model_path
```
3. Download draft model from HuggingFace Hub
```python
import huggingface_hub as hf_hub
draft_model_id = "OpenVINO/Llama-3.1-8B-Instruct-FastDraft-150M"
draft_model_path = "draft"
hf_hub.snapshot_download(draft_model_id, local_dir=draft_model_path)
```
4. Run model inference using the speculative decoding and specify the pipeline parameters:
```python
import openvino_genai
prompt = “What is OpenVINO?”
config = openvino_genai.GenerationConfig()
config.num_assistant_tokens = 3
config.max_new_tokens = 128
def streamer(subword):
print(subword, end='', flush=True)
return False
main_device = "CPU"
draft_device = "CPU"
draft_model = openvino_genai.draft_model(draft_model_path, draft_device)
scheduler_config = openvino_genai.SchedulerConfig()
scheduler_config.cache_size = 2
pipe = openvino_genai.LLMPipeline(main_model_path, main_device, scheduler_config=scheduler_config, draft_model=draft_model)
pipe.generate(prompt, config, streamer)
```
More GenAI usage examples can be found in OpenVINO GenAI library [docs](https://github.com/openvinotoolkit/openvino.genai/blob/master/src/README.md) and [samples](https://github.com/openvinotoolkit/openvino.genai/tree/master/samples)
## Disclaimer
Intel is committed to respecting human rights and avoiding causing or contributing to adverse impacts on human rights. See [Intel’s Global Human Rights Principles](https://www.intel.com/content/dam/www/central-libraries/us/en/documents/policy-human-rights.pdf). Intel’s products and software are intended only to be used in applications that do not cause or contribute to adverse impacts on human rights. |