Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inference params Support in Model Predict #200

Merged
merged 9 commits into from
Nov 2, 2023

Conversation

sainivedh
Copy link
Contributor

@sainivedh sainivedh commented Oct 18, 2023

Model Predict

# Note: CLARIFAI_PAT must be set as env variable.
from clarifai.client.model import Model

"""
Get Model information on details of model(description, usecases..etc) and info on training or
# other inference parameters(eg: temperature, top_k, max_tokens..etc for LLMs)
"""
gpt_4_model = Model("https://clarifai.com/openai/chat-completion/models/GPT-4")
print(gpt_4_model)


# Customizing Model Inference Output
model_prediction = gpt_4_model.predict_by_bytes(b"Write a tweet on future of AI", "text", inference_params=dict(temperature=str(0.7), max_tokens=30))
# Return predictions having prediction confidence > 0.98
model_prediction = model.predict_by_filepath(filepath="local_filepath", input_type, output_config={"min_value": 0.98}) # Supports image, text, audio, video

# Return predictions for specified interval of video
video_input_proto = [input_obj.get_input_from_url("Input_id", video_url=BEER_VIDEO_URL)]
model_prediction = model.predict(video_input_proto, input_type="video", output_config={"sample_ms": 2000})

@sainivedh sainivedh changed the title Add inference params and remove input_type in predict Add inference params Support in Model Predict Oct 31, 2023
@sainivedh sainivedh marked this pull request as ready for review October 31, 2023 15:29
@sainivedh sainivedh marked this pull request as draft November 2, 2023 06:56
@sainivedh sainivedh marked this pull request as ready for review November 2, 2023 07:15
Copy link
Contributor

@sanjaychelliah sanjaychelliah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
One minor comment..

clarifai/client/model.py Show resolved Hide resolved
@sainivedh sainivedh merged commit f036545 into master Nov 2, 2023
@sainivedh sainivedh deleted the DEVX-222-model-inference-params branch November 2, 2023 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants