Friday, August 18, 2023

StableCode Local Installation - Step by Step Guide with Commands

 This video tutorial shows you how to easily install StableCode from StabilityAI which is an AI code generator and assistant. 



Commands Used:


!pip install transformers

!pip install --upgrade huggingface_hub

from huggingface_hub import login

login(token="<Get your own AccessToken from HuggingFace>")


!git clone https://github.com/PanQiWei/AutoGPTQ

cd AutoGPTQ

!pip3 install .


from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig

model_name_or_path = "stabilityai/stablecode-instruct-alpha-3b"

use_triton = False

tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)


model = AutoModelForCausalLM.from_pretrained(

  "stabilityai/stablecode-instruct-alpha-3b",

  trust_remote_code=True,

  torch_dtype="auto",

)


prompt = "Generate a Python Program to Print the Fibonacci sequence"

prompt_template=f'''### Instruction:

{prompt}

### Response:

'''

print("\n\n*** Generate:")


logging.set_verbosity(logging.CRITICAL)


print("*** Pipeline:")

pipe = pipeline(

    "text-generation",

    model=model,

    tokenizer=tokenizer,

    max_new_tokens=512,

    temperature=0.7,

    top_p=0.95,

    repetition_penalty=1.15

)


print(pipe(prompt_template)[0]['generated_text'])


Enjoy!!!!



No comments: