Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated docs with load_in_4bit #558

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading