Instructions to use deepcode-ai/deepcode-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepcode-ai/deepcode-base with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import MultiModalityCausalLM model = MultiModalityCausalLM.from_pretrained("deepcode-ai/deepcode-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files12345---license: otherlicense_name: deepcode-licenselicense_link: LICENSE---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566---license: otherlicense_name: deepcode-ailicense_link: LICENSE---## 3. Quick Start### InstallationOn the basis of `Python >= 3.8` environment, install the necessary dependencies by running the following command:```shellgit clone https://github.com/deepcode-ai/DeepCode-VL-VLcd DeepCode-VL-VLpip install -e .```### Simple Inference Example```pythonimport torchfrom transformers import AutoModelForCausalLMfrom deepcode_vl.models import VLChatProcessor, MultiModalityCausalLMfrom deepcode_vl.utils.io import load_pil_images# specify the path to the modelmodel_path = "deepcode-ai/deepcode-base"vl_chat_processor: VLChatProcessor = VLChatProcessor.from_pretrained(model_path)tokenizer = vl_chat_processor.tokenizervl_gpt: MultiModalityCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()conversation = [{"role": "User","content": "<image_placeholder>Describe each stage of this image.","images": ["./images/training_pipelines.png"]},{"role": "Assistant","content": ""}]# load images and prepare for inputspil_images = load_pil_images(conversation)prepare_inputs = vl_chat_processor(conversations=conversation,images=pil_images,force_batchify=True).to(vl_gpt.device)# run image encoder to get the image embeddingsinputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs)# run the model to get the responseoutputs = vl_gpt.language_model.generate(inputs_embeds=inputs_embeds,attention_mask=prepare_inputs.attention_mask,pad_token_id=tokenizer.eos_token_id,bos_token_id=tokenizer.bos_token_id,eos_token_id=tokenizer.eos_token_id,max_new_tokens=512,do_sample=False,use_cache=True)answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=True)print(f"{prepare_inputs['sft_format'][0]}", answer)```### CLI Chat```bashpython cli_chat.py --model_path "deepcode-ai/deepcode-base"# or local pathpython cli_chat.py --model_path "local model path"``
README.md+63-2