CoolFace
Modelpublic

aiplanet/panda-coder-13B

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
14likes34downloads
README.md206 linesDownload Raw Back to root
1---2library_name: transformers3license: apache-2.04datasets:5- TokenBender/code_instructions_122k_alpaca_style6- nickrosh/Evol-Instruct-Code-80k-v17metrics:8- accuracy9language:10- en11widget:12- text: |13    ### Instruction: write a neural network complete code in Keras 14    ### Input: Use cifar dataset 15    ### Response:16  output:17    text: >-18      from keras.datasets import cifar10 import numpy as np from keras.models19      import Sequential from keras.layers import Dense, Dropout, Activation,20      Flatten from keras.layers import Conv2D, MaxPooling2D from keras.utils21      import to_categorical from keras.optimizers import Adam22 23      # Load the CIFAR-10 dataset (X_train, y_train), (X_test, y_test) =24      cifar10.load_data()25 26      # Normalize pixel values to be between 0 and 1 X_train =27      X_train.astype('float32') / 255 X_test = X_test.astype('float32') / 25528 29      # Convert class vectors to binary class matrices y_train =30      to_categorical(y_train, num_classes=10) y_test = to_categorical(y_test,31      num_classes=10)32 33      # Create the model model = Sequential() model.add(Conv2D(32, (3, 3),34      input_shape=(32, 32, 3))) model.add(Activation('relu'))35      model.add(MaxPooling2D(pool_size=(2, 2)))36 37      model.add(Conv2D(64, (3, 3))) model.add(Activation('relu'))38      model.add(MaxPooling2D(pool_size=(2, 2)))39 40      model.add(Flatten()) model.add(Dense(64)) model.add(Activation('relu'))41      model.add(Dropout(0.5)) model.add(Dense(10))42      model.add(Activation('softmax'))43 44      # Compile the model model.compile(loss='categorical_crossentropy',45      optimizer=Adam(), metrics=['accuracy'])46 47      # Train the model model.fit(X_train, y_train, batch_size=32, epochs=10,48      validation_split=0.2)49pipeline_tag: text-generation50base_model: codellama/CodeLlama-13b-Instruct-hf51---52 53<p align="center" style="font-size:34px;"><b>Panda-Coder ๐Ÿผ</b></p>54 55# Panda Coder-13B vLLM Inference: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1yP-11PWqLrDn5ymKDWMfz9r6jLpTcTAH?usp=sharing)56 57![Opensource L.png](https://cdn-uploads.huggingface.co/production/uploads/630f3058236215d0b7078806/BmrdSXe_vZUNxTHopwd3M.png)58 59 Panda Coder is a state-of-the-art LLM capable of generating code on the NLP based Instructions60 61 ## Model description62 63 ๐Ÿค– Model Description: Panda-Coder is a state-of-the-art LLM, a fine-tuned model, specifically designed to generate code based on natural language instructions. It's the result of relentless innovation and meticulous fine-tuning, all to make coding easier and more accessible for everyone.64 65## Inference 66 67> Hardware requirements:68>69> 30GB VRAM - A100 Preferred70 71### vLLM - For Faster Inference72 73#### Installation74 75```76!pip install vllm77```78 79**Implementation**:80 81```python82from vllm import LLM, SamplingParams83 84llm = LLM(model='aiplanet/panda-coder-13B',gpu_memory_utilization=0.95,max_model_len=4096)85 86prompts = [""" ### Instruction: Write a Java code to add 15 numbers randomly generated.87### Input: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]88### Response:89""",90"### Instruction: write a neural network complete code in Keras ### Input: Use cifar dataset ### Response:"91]92 93sampling_params = SamplingParams(temperature=0.1, top_p=0.95,repetition_penalty = 1.1,max_tokens=1000)94 95outputs = llm.generate(prompts, sampling_params)96 97for output in outputs:98    prompt = output.prompt99    generated_text = output.outputs[0].text100    print(generated_text)101    print("\n\n")102```103 104 105### Transformers - Basic Implementation106 107```python108import torch109import transformers110from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments,BitsAndBytesConfig111 112bnb_config = BitsAndBytesConfig(113    load_in_4bit=True,114    bnb_4bit_use_double_quant=True,115    bnb_4bit_quant_type="nf4",116    bnb_4bit_compute_dtype=torch.bfloat16117)118 119model = "aiplanet/panda-coder-13B"120 121base_model = AutoModelForCausalLM.from_pretrained(model, quantization_config=bnb_config, device_map="cuda")122 123tokenizer = AutoTokenizer.from_pretrained(model, trust_remote_code=True)124tokenizer.pad_token = tokenizer.eos_token125tokenizer.padding_side = "right"126 127prompt = f"""### Instruction:128Below is an instruction that describes a task. Write a response that appropriately completes the request.129 130Write a Python quickstart script to get started with TensorFlow131 132### Input:133 134### Response:135"""136 137input_ids = tokenizer(prompt, return_tensors="pt", truncation=True).input_ids.cuda()138outputs = base_model.generate(input_ids=input_ids, max_new_tokens=512, do_sample=True, top_p=0.9,temperature=0.1,repetition_penalty=1.1)139 140print(f"Output:\n{tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0][len(prompt):]}")141```142 143Output144 145```bash146Output:147import tensorflow as tf148 149# Create a constant tensor150hello_constant = tf.constant('Hello, World!')151 152# Print the value of the constant153print(hello_constant)154```155 156## Prompt Template for Panda Coder 13B157 158```159### Instruction:160{<add your instruction here>}161 162### Input:163{<can be empty>}164 165### Response:166```167 168 ## ๐Ÿ”— Key Features:169 170 ๐ŸŒŸ NLP-Based Coding: With Panda-Coder, you can transform your plain text instructions into functional code effortlessly. No need to grapple with syntax and semantics - it understands your language.171 172 ๐ŸŽฏ Precision and Efficiency: The model is tailored for accuracy, ensuring your code is not just functional but also efficient.173 174 โœจ Unleash Creativity: Whether you're a novice or an expert coder, Panda-Coder is here to support your coding journey, offering creative solutions to your programming challenges.175 176 ๐Ÿ“š Evol Instruct Code: It's built on the robust Evol Instruct Code 80k-v1 dataset, guaranteeing top-notch code generation.177 178 ๐Ÿ“ข What's Next?: We believe in continuous improvement and are excited to announce that in our next release, Panda-Coder will be enhanced with a custom dataset. This dataset will not only expand the language support but also include hardware programming languages like MATLAB, Embedded C, and Verilog. ๐Ÿงฐ๐Ÿ’ก179 180 ## Get in Touch181 182 183 You can schedule 1:1 meeting with our DevRel & Community Team to get started with AI Planet Open Source LLMs and GenAI Stack. Schedule the call here: [https://calendly.com/jaintarun](https://calendly.com/jaintarun)184 185 Stay tuned for more updates and be a part of the coding evolution. Join us on this exciting journey as we make AI accessible to all at AI Planet!186 187 188 189 ### Framework versions190 191- Transformers 4.33.3192- Pytorch 2.0.1+cu118193- Datasets 2.14.5194- Tokenizers 0.13.3195 196 ### Citation197 198 ```199 @misc {lucifertrj,200	author       = { {Tarun Jain} },201	title        = { Panda Coder-13B by AI Planet},202	year         = 2023,203	url          = { https://huggingface.co/aiplanet/panda-coder-13B },204	publisher    = { Hugging Face }205}206 ```