Skip to content

Commit

Permalink
Updated docs with load_in_4bit (#558)
Browse files Browse the repository at this point in the history
* Updated docs with load_in_4bit

* Update documentation

* Update documentation

* typo

---------

Co-authored-by: Ella Charlaix <ella@huggingface.co>
  • Loading branch information
AlexKoff88 and echarlaix authored Feb 21, 2024
1 parent 18ba0bd commit c7e228f
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions docs/source/optimization_ov.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,16 @@ model = OVModelForCausalLM.from_pretrained(model_id, load_in_8bit=True)

> **NOTE:** `load_in_8bit` is enabled by default for models larger than 1 billion parameters.

For the 4-bit weight quantization we recommend using the NNCF API like below:
For the 4-bit weight quantization you can use the `quantization_config` to specify the optimization parameters, for example:

```python
from optimum.intel import OVModelForCausalLM
import nncf

model = OVModelForCausalLM.from_pretrained(model_id, load_in_8bit=False)
model.model = nncf.compress_weights(
model.model,
mode=nncf.CompressWeightsMode.INT4_SYM,
ratio=0.8,
group_size=128,
)
model.save_pretrained("compressed_model")
from optimum.intel import OVModelForCausalLM, OVWeightQuantizationConfig

model = OVModelForCausalLM.from_pretrained(
model_id,
export=True,
quantization_config=OVWeightQuantizationConfig(bits=4, sym=False, ratio=0.8, dataset="ptb"),
)
```

For more details, please refer to the corresponding NNCF [documentation](https://github.com/openvinotoolkit/nncf/blob/develop/docs/compression_algorithms/CompressWeights.md).
Expand Down

0 comments on commit c7e228f

Please sign in to comment.