Skip to content

Instantly share code, notes, and snippets.

@billmetangmo
Created August 26, 2024 15:13
Show Gist options
  • Save billmetangmo/852a9960d13be5064cd8810b6c20e0e3 to your computer and use it in GitHub Desktop.
Save billmetangmo/852a9960d13be5064cd8810b6c20e0e3 to your computer and use it in GitHub Desktop.
Test outlines for tool extraction using modal
title date author categories tags
Meeting 36
2024-08-07
collectif mongulu
Meeting notes
generative-ai
data-tools
developer-tools
devops
machine-learning

Recommandations


Developer

Data

Devops

Machine Learning

Generative AI

import modal
from pydantic import BaseModel
from typing import List
app = modal.App("test-microsoft-mini")
image = modal.Image.debian_slim() # start from basic Linux image
image = image.pip_install("outlines","torch","transformers") # add neural network libraries
image = image.pip_install("torch")
image = image.pip_install("transformers")
@app.function(gpu="H100",image=image,mounts=[modal.Mount.from_local_dir(".", remote_path="/root/")]) # defining a Modal Function with a GPU
def extract_info():
import outlines
with open('notes.md', 'r') as file:
content = file.read()
print(content)
class Tool(BaseModel):
name: str
category: str
description: str
link: str
class Tools(BaseModel):
tools: List[Tool]
model = outlines.models.transformers("microsoft/Phi-3-mini-4k-instruct")
generator = outlines.generate.json(model, Tool)
tools =generator("""
[INST] Extract only tools from the provided text:
{content}
[/INST]
""")
print(tools)
@app.local_entrypoint()
def main():
#check_gpus.remote()
extract_info.remote()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment