# Avoid loading checkpoint shards for each inference

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Favoid-loading-checkpoint-shards-for-each-inference%2F66357%3E%5C
**Category:** 🤗Transformers\
**Created:** [December 19, 2023, 3:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Favoid-loading-checkpoint-shards-for-each-inference%2F66357 "2023-12-19T15:35:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alzaia](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@alzaia](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Falzaia)%5C
**Post date:** [December 19, 2023, 3:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Favoid-loading-checkpoint-shards-for-each-inference%2F66357%2F1 "2023-12-19T15:35:33Z")

</div>

I am currently using LLaVA for inference and I was wondering if there was a way to avoid reloading the checkpoint shards every time I predict a new sample. For reference, I am closely following the doc and the colab here: [llava-hf/llava-1.5-7b-hf · Hugging Face](https://huggingface.co/llava-hf/llava-1.5-7b-hf).

---

<div class="post-metadata">

**Author:** ![enochlev](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/enochlev/32/22267_2.png) [@enochlev](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fenochlev)%5C
**Post date:** [December 19, 2023, 6:31pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Favoid-loading-checkpoint-shards-for-each-inference%2F66357%2F2 "2023-12-19T18:31:22Z")

</div>

provide us with a snippet from your code

otherwize I can only say don’t call this function every time you do an inference

```auto
LlavaForConditionalGeneration.from_pretrained

```

---

<div class="post-metadata">

**Author:** ![alzaia](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@alzaia](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Falzaia)%5C
**Post date:** [December 19, 2023, 7:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Favoid-loading-checkpoint-shards-for-each-inference%2F66357%2F3 "2023-12-19T19:48:56Z")

</div>

I’m using the pipeline from HuggingFace, so my code is super simple:

```auto
        image = Image.open(image_path)

        pipe = pipeline(
            "image-to-text",
            model=model_id,
            model_kwargs={"quantization_config": quantization_config},
        )

        output = pipe(
            image, prompt=text_prompt, generate_kwargs={"max_new_tokens": 200}
        )

```

Should I use pure transformers library instead to have more control?
