zinoubm's picture
new solution
fa9bc9f
import gradio as gr
from qdrant import qdrant_manager
from openai_manager import openai_manager
description = """
In this project, Im using Few-Shot Learning as an alternative to Fine-Tuning and Prompt
Engineering methods. While Prompt Engineering offers a cost-effective and swift approach
for development, it falls short in providing a comprehensive level of instruction
definition. For instance, crafting instructions that simulate a specific writing style proves to be exceptionally challenging.
On the other hand, Fine-Tuning excels in terms of instruction integration as it
comprehends and learns instructions rather than merely receiving them. However, it
comes with challenges such as complexity, high costs, and time-intensive processes.
Few-Shot Learning elegantly positions itself between these two approaches, offering the
best of both worlds. It provides an enticing balance that you might want to explore.
Why not give it a try?
This model works by providing a set of keywords separated by "," and It will return a Sales script To train you employees for different senarios.
"""
def generate(keywords):
try:
keywords_list = list(map(lambda x: x.strip(), keywords.split(",")))
except:
keywords_list = []
gr.Warning("Please use ',' to separate Keywords")
embedding = openai_manager.get_embedding(" ".join(keywords_list))
points = qdrant_manager.search_point(query_vector=embedding)
return openai_manager.shots(points, " ".join(keywords_list))
iface = gr.Interface(
fn=generate,
examples=[
" Technology, Products, Returns, Warranty",
" Energy, Warranty, Customer Service, Refund",
],
inputs="text",
outputs="text",
title="Sales Role Play Generator - Few Shots Learning",
description=description,
)
iface.launch()