Downloads · 30 days
19
23% of all-time downloads
pikhan/gpt2-medium-biochem-bioasq-pubmedqa-demo
gpt2-medium-biochem-bioasq-pubmedqa-demo is a text generation model from pikhan. Use it when you need the model to write or continue text. It is set up for transformers.
datasets: - qiaojin/PubMedQA - kroshan/BioASQ language: - en libraryname: transformers pipelinetag: table-question-answering tags: - chemistry - biology - molecular - synthetic - language model Description: This model…
Downloads · 30 days
19
23% of all-time downloads
All-time downloads
84
Public
Parameters
355M
710 MB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors710 MB · 100%
From the Hugging Face model README
datasets:
Intel Optimization Inference Code Sample: We made use of both the BF16 datatype and INT8 quantization to improve performance. BF16 halves the memory compared to FP32, allowing larger models and/or larger batches to fit into memory. Moreover, BF16 is supported by modern Intel CPUs and operations with it are optimized. Quantizing models to INT8 can reduce the model size, making better use of cache and speeding up load times. Additionally, we then optimized further with OpenVino to make it run better on Intel Hardware by converting it to an onxx model to then OpenVINO Intermediate Representation
from openvino.runtime import Core import numpy as np
ie = Core()
compiled_model = ie.compile_model(model='../ovc_output/converted_model.xml', device_name="CPU")
input_ids = np.random.randint(0, 50256, (1, 10))
inputs = {"input_ids": input_ids}
result = compiled_model.create_infer_request().infer(inputs=inputs)
output = result['outputs']
print("Inference results:", output) In the finetuning file you will see our other optimizations.
We perform BF16 conversion as follows (we also implement a custom collator):
model = GPT2LMHeadModel.from_pretrained('gpt2-medium').to(torch.bfloat16) We perform Int8 quantization as follows:
model.eval() # Ensure the model is in evaluation mode quantized_model = quantize_dynamic(model, {torch.nn.Linear}, dtype=torch.qint8)