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

Add a cpu example of HuggingFace Transformers Agent (use vicuna-7b-v1.5) #9284

Merged
merged 4 commits into from
Oct 27, 2023

Conversation

yzheng124
Copy link
Contributor

@yzheng124 yzheng124 commented Oct 26, 2023

Description

1. Why the change?

In this PR, we add an cpu examples of HuggingFace Transformers Agent. This example uses vicuna-7b-v1.5 and generates caption for an input image.

The demo.jpg is from COCO2017 train set (000000264959.jpg).

https://github.com/analytics-zoo/nano/issues/669

@yzheng124 yzheng124 changed the title Add cpu examples of HuggingFace Transformers Agent (use vicuna-7b-v1.5) Add a cpu example of HuggingFace Transformers Agent (use vicuna-7b-v1.5) Oct 26, 2023
@yzheng124
Copy link
Contributor Author

Hi @shane-huang , please take a look. Thanks!


# Generate results
print(f"Image path: {args.image_path}")
print(agent.run("Generate a caption for the 'image'", image=image))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print the prompt as well so that readers will know this is for image caption generation.

# BigDL-LLM Transformers INT4 Optimization for HuggingFace Transformers Agent
In this directory, you will find examples on how you could apply BigDL-LLM INT4 optimizations on HuggingFace Transformers Agent. For illustration purposes, we utilize the [lmsys/vicuna-7b-v1.5](https://huggingface.co/lmsys/vicuna-7b-v1.5) as the reference model.

## 0. Requirements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Requirements and Best Known Configurations, and put a reference to https://github.com/intel-analytics/BigDL/tree/main/python/llm/example/CPU/HF-Transformers-AutoModels/Model#recommended-requirements as other examples in HF-Transformers-AutoModels/Model

source bigdl-nano-init
```

## Example: Run an agent using `run()` API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the lines

Example: Run an agent using run() API
In the example run_agent.py, we show a basic use case of using run() API to run an agent, which uses Vicuna model with BigDL-LLM INT4 optimizations.

@@ -6,6 +6,7 @@ This folder contains examples of running BigDL-LLM on Intel CPU:
- [PyTorch-Models](PyTorch-Models): running any PyTorch model on BigDL-LLM (with "one-line code change")
- [Native-Models](Native-Models): converting & running LLM in `llama`/`chatglm`/`bloom`/`gptneox`/`starcoder` model family using native (cpp) implementation
- [LangChain](LangChain): running LangChain applications on BigDL-LLM
- [Application](Application): running Transformers applications on BigDl-LLM
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change folder from CPU/Application to CPU/Applications

a little girl holding a stuffed teddy bear
```

### 3. Reference
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove section 3. No need to tell user how to download it. And using coco image is okay but using image source directly from flicker may cause issues.

Copy link
Contributor

@shane-huang shane-huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@shane-huang shane-huang merged commit 3830ffe into intel-analytics:main Oct 27, 2023
29 of 30 checks passed
liu-shaojun pushed a commit that referenced this pull request Mar 25, 2024
….5) (#9284)

* Add examples of HF Agent

* Modify folder structure and add link of demo.jpg

* Fixes of readme

* Merge applications and Applications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants