Instructions to use rapidoradhilabacker/pndoc_model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rapidoradhilabacker/pndoc_model with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("rapidoradhilabacker/pndoc_model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use rapidoradhilabacker/pndoc_model with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for rapidoradhilabacker/pndoc_model to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for rapidoradhilabacker/pndoc_model to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for rapidoradhilabacker/pndoc_model to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="rapidoradhilabacker/pndoc_model", max_seq_length=2048, )
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| import torch | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| # Load model and tokenizer | |
| self.tokenizer = AutoTokenizer.from_pretrained(path) | |
| self.model = AutoModelForCausalLM.from_pretrained( | |
| path, | |
| torch_dtype=torch.float16, | |
| device_map="auto" | |
| ) | |
| def __call__(self, data): | |
| # Parse the input data | |
| inputs = data.pop("inputs", data) | |
| parameters = data.pop("parameters", {}) | |
| # Set default parameters if not provided | |
| max_new_tokens = parameters.get("max_new_tokens", 256) | |
| temperature = parameters.get("temperature", 0.7) | |
| do_sample = parameters.get("do_sample", True) | |
| # Tokenize and generate | |
| input_ids = self.tokenizer(inputs, return_tensors="pt").input_ids.to(self.model.device) | |
| with torch.no_grad(): | |
| outputs = self.model.generate( | |
| input_ids, | |
| max_new_tokens=max_new_tokens, | |
| do_sample=do_sample, | |
| temperature=temperature, | |
| **parameters | |
| ) | |
| response = self.tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| return {"generated_text": response} |