GithubHelp home page GithubHelp logo

Comments (4)

mayank31398 avatar mayank31398 commented on August 14, 2024 1

@garyyang85 I see
currently, there is VLLM integration underway: vllm-project/vllm#4636

from granite-code-models.

mayank31398 avatar mayank31398 commented on August 14, 2024

HI @garyyang85 , having trouble understanding the request.
Can you clarify?
There is an example in the README.md

you will need to install transformers from source for this though.

cross-pasting here as well:

from transformers import AutoModelForCausalLM, AutoTokenizer

device = "cuda" # or "cpu"
model_path = "ibm-granite/granite-3b-code-base" # pick anyone from above list

tokenizer = AutoTokenizer.from_pretrained(model_path)

# drop device_map if running on CPU
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
model.eval()

# change input text as desired
input_text = "def generate():"
# tokenize the text
input_tokens = tokenizer(input_text, return_tensors="pt")

# transfer tokenized inputs to the device
for i in input_tokens:
    input_tokens[i] = input_tokens[i].to(device)

# generate output tokens
output = model.generate(**input_tokens)
# decode output tokens into text
output = tokenizer.batch_decode(output)

# loop over the batch to print, in this example the batch size is 1
for i in output:
    print(i)

from granite-code-models.

garyyang85 avatar garyyang85 commented on August 14, 2024

Hi @mayank31398 Thanks for your response.
Popular models may included in fastchat. I mean something like the api server in fastchat. It will load model only once and then accept standard openai request, return the stream answer. Like this: https://github.com/baichuan-inc/Baichuan2/blob/main/OpenAI_api.py
For test purpose, maybe Flask is enough. Of course I can follow the sample code to build one myself. :)

from granite-code-models.

mayank31398 avatar mayank31398 commented on August 14, 2024

@garyyang85 vllm-project/vllm#4636 is merged now.
closing this.

from granite-code-models.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.