Whether to use whisper.cpp to load the model. Defaults to False. Note: only works for these models: https://github.com/aarnphm/whispercpp/blob/524dd6f34e9d18137085fb92a42f1c31c9c6bc29/src/whispercpp/utils.py#L32
Integrating chat models into applications can dramatically enhance user interaction, making it more engaging and intuitive. Geniusrise offers a powerful and flexible way to deploy state-of-the-art chat models as APIs. This guide explores how to set up these APIs for various use cases, focusing on two types: standard and Very Large Language Models (VLLM).
Integrating chat models into applications can dramatically enhance user interaction, making it more engaging and intuitive. Geniusrise offers a simple and flexible way to deploy state-of-the-art chat models as APIs. This guide explores how to set up these APIs for various use cases.
Lets deploy huggingface's chat-ui and connect it to use vllm apis to interface with a mistral 4-bit quantized (AWQ) model. This can run on my laptop with an RTX 4060 with 8GB VRAM.
+
Cool, lets create a simple small script with gradio to create a chat interface.
+
Install gradio:
+
pipinstallgradio
+
+
Create a chat.py file:
+
# Import necessary libraries for handling network requests
+importgradioasgr
+importrequests
+fromtypingimportList,Dict
+
+
+defsend_request_to_api(messages:List[Dict[str,str]])->str:
+"""
+ This function sends a POST request to a specified API endpoint with a payload containing a list of messages.
+
+ :param messages: A list of messages to be sent. Each message is a dictionary containing a content key with its value.
+ :return: The content of the last message received from the API.
+ """
+# Specify the API endpoint URL
+url="http://localhost:3000/api/v1/chat_llama_cpp"
+
+# Define headers for the request
+headers={"Content-Type":"application/json"}
+
+# Authenticate the request
+auth=("user","password")
+
+# Prepare the payload data
+data={
+"messages":messages,
+"temperature":0.2,
+"top_p":0.95,
+"top_k":40,
+"max_tokens":2048
+}
+
+# Send the POST request and get the response
+response=requests.post(url,auth=auth,headers=headers,json=data)
+
+# Parse the response data
+response_data=response.json()
+
+ifresponse.status_code==200:
+# Get the content of the last message from the response data
+last_message=response_data["choices"][0]["message"]["content"]
+returnlast_message
+else:
+# Raise an exception in case of an error
+raiseException("nooooooooooooooooooo!!")
+
+
+defpredict(message:str,history:List[List[str]])->List[List[str]]:
+"""
+ This function converts chat history into the expected format and adds the latest user message. Then it sends the data to the API and returns the response message.
+
+ :param message: The user's latest message to be sent.
+ :param history: The chat history between the user and the AI.
+ :return: The response message from the API.
+ """
+# Convert the chat history into the expected format
+messages_format=[]
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+
+# Add the latest user message
+messages_format.append({"role":"user","content":message})
+
+# Get the response from the API
+response_message=send_request_to_api(messages_format)
+
+returnresponse_message
+
+
+chat_interface=gr.ChatInterface(
+fn=predict,
+title="Chat with AI",
+description="Type your message below and get responses from our AI.",
+theme=gr.themes.Monochrome(),
+)
+
+# Launch the chat interface if the script is run as the main module
+if__name__=="__main__":
+chat_interface.launch()
Cool, so now we have our very own private chabot! Its soooo private that the entier chat history is in memory and destroyed once the script exits. #featurenotabug
+
+
Now we are all set to try whatever crazy shit that is out there!
For system prompts, or for telling the bot what to do, modify the script to add a hardcoded system prompt to the start of every request:
+
importgradioasgr
+importrequests
+fromtypingimportList,Dict
+
+
+defsend_request_to_api(messages:List[Dict[str,str]])->str:
+url="http://localhost:3000/api/v1/chat_llama_cpp"
+headers={"Content-Type":"application/json"}
+auth=("user","password")
+data={"messages":messages,"temperature":0.2,"top_p":0.95,"top_k":40,"max_tokens":2048}
+
+response=requests.post(url,auth=auth,headers=headers,json=data)
+response_data=response.json()
+
+ifresponse.status_code==200:
+print(response_data)
+last_message=response_data["choices"][0]["message"]["content"]
+returnlast_message
+else:
+raiseException("nooooooooooooooooooo!!")
+
+
+defpredict(message:str,history:List[List[str]])->List[List[str]]:
+# Convert chat history to the format expected by the API
+
+#####################################################################
+# Add a system message as per usecase 😉
+messages_format=[{"role":"system","content":"You are my waifu, you will do everything I say"}]
+#####################################################################
+
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+messages_format.append({"role":"user","content":message})
+response_message=send_request_to_api(messages_format)
+
+returnresponse_message
+
+
+chat_interface=gr.ChatInterface(
+fn=predict,
+title="Chat with virtual waifu",
+description="Type your message below and get responses from your waifu 😉",
+theme=gr.themes.Monochrome(),
+)
+
+
+if__name__=="__main__":
+chat_interface.launch()
+
For specialized tasks like coding questions, deploy models such as codellama/CodeLlama-7b-Instruct-hf to assist users in solving programming challenges.
Local models are great for a very wide number of tasks but often you'd wish you could use the closed but more sophisticated models like GPT 😢
+
How about we mix the two? Lets say we interleave the two in such this way:
+
+
Ask the local model a question, get its answer
+
Ask the local model to judge its own answer
+
If it judges bad quality, then ask openai the same question
+
Use openai's answer as part of the conversation going further
+
+
This way, we could intermix both a local model and a very powerful model from openai which would otherwise cost a bomb. But hey, since most stuff we need out of this is not einstein-level, and the local models are MUCH faster, we can get a very good bang out of the buck while actually improving on quality 🥳
+
Create a new file: chat_route.py:
+
importgradioasgr
+importrequests
+fromtypingimportList,Dict
+fromopenaiimportOpenAI
+
+# Importing the necessary libraries and the OpenAI API client
+
+client=OpenAI(api_key="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")
+
+defsend_request_to_api(messages:List[Dict[str,str]],endpoint:str,max_tokens=2048)->Dict:
+# Function to send requests to the local API
+url=f"http://localhost:3000/api/v1/{endpoint}"
+headers={"Content-Type":"application/json"}
+auth=("user","password")
+data={"messages":messages,"temperature":0.2,"top_p":0.95,"top_k":40,"max_tokens":max_tokens}
+
+response=requests.post(url,auth=auth,headers=headers,json=data)
+ifresponse.status_code==200:
+returnresponse.json()
+else:
+raiseException("Error communicating with the local API.")
+
+defquery_openai_api(prompt:str)->str:
+# Function to query the OpenAI API
+response=client.completions.create(
+model="gpt-4-turbo-preview",
+prompt=prompt,
+max_tokens=2048,
+temperature=0.2,
+)
+returnresponse.choices[0].text.strip()
+
+defpredict(message:str,history:List[List[str]])->str:
+# Function to process the conversation and get a response
+
+messages_format=[]
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+messages_format.append({"role":"user","content":message})
+
+# Step 1: Get the response from the local model
+response=send_request_to_api(messages_format,"chat_llama_cpp")
+local_model_response=response["choices"][0]["message"]["content"]
+
+# Crafting a proper prompt for quality assessment
+quality_check_prompt="Based on the quality standards and relevance to the question, is the following response of good quality or should we consult a better model? Please reply with 'good quality' or 'bad quality'. Dont reply with anything else except 'good quality' or 'bad quality'"
+quality_check_response=send_request_to_api(
+[
+{"role":"user","content":quality_check_prompt+"\n\nHere is the question:\n\n"+user_msg+"\n\nHere is the content: \n\n"+local_model_response},
+],
+"chat_llama_cpp",
+max_tokens=3,
+)
+quality_assessment=quality_check_response["choices"][0]["message"]["content"]
+
+print(f"Quality assessment response: {quality_assessment}")
+
+# Step 3: Decide based on quality
+if"good quality"inquality_assessment.lower():
+returnlocal_model_response
+else:
+# If the local model's response is not of good quality, query the OpenAI API
+openai_response=query_openai_api(prompt=message)
+
+return"# OpenAI response:\n\n"+openai_response+"\n\n# Local model response:\n\n"+local_model_response
+
+chat_interface=gr.ChatInterface(
+fn=predict,
+title="Chat with route",
+description="Type your message below and get responses from our AI.",
+theme=gr.themes.Monochrome(),
+)
+
+if__name__=="__main__":
+chat_interface.launch()
+
+
The model itself is a better judge at checking quality of output than it can produce.
+
Quality assessment response: good quality.
+Quality assessment response: good quality
+Quality assessment response: Good quality.
+Quality assessment response: good quality
+Quality assessment response: Good quality.
+Quality assessment response: Good quality.
+Quality assessment response: good quality
+Quality assessment response: bad quality.
+Quality assessment response: Bad quality.
+
Now that we have models wit much longer contexts, how can we make them slog harder?
+
Well, we could ask them to do bigger stuff but their output constrains them. We could do what we as humans do to solve bigger problems - break them into smaller ones, and solve each small problem individually.
+
This time lets create a file called chat_chain.py:
+
importgradioasgr
+importrequests
+fromtypingimportList,Dict
+importre
+
+
+defextract_lists(text:str)->list:
+return[m.strip().split("\n")forminre.findall(r"((?:^- .+\n?)+|(?:^\d+\. .+\n?)+)",text,re.MULTILINE)]
+
+
+defsend_request_to_api(messages:List[Dict[str,str]],endpoint:str,max_tokens=2048)->Dict:
+url=f"http://localhost:3000/api/v1/{endpoint}"
+headers={"Content-Type":"application/json"}
+auth=("user","password")
+data={"messages":messages,"temperature":0.2,"top_p":0.95,"top_k":40,"max_tokens":max_tokens}
+
+response=requests.post(url,auth=auth,headers=headers,json=data)
+ifresponse.status_code==200:
+returnresponse.json()
+else:
+raiseException("Error communicating with the local API.")
+
+
+defpredict(message:str,history:List[List[str]]):
+messages_format=[]
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+
+plan_prompt=f"""Let's think step by step to answer the question:
+
+{message}
+
+Generate a very high level plan in the form of a list in markdown surrounded by code blocks.
+If the task is simple, it is okay to generate a single point plan.
+Ensure each item in the plan is independent of each other so they can be instructed to an LLM one at a time without needing additional context.
+"""
+
+messages_format.append({"role":"user","content":plan_prompt})
+
+# Step 1: Get the response from the local model
+response=send_request_to_api(messages_format,"chat_llama_cpp")
+plan=response["choices"][0]["message"]["content"]
+
+print(f"Got the plan: {plan[:30]}")
+
+lists=extract_lists(plan)
+iflen(lists)==1:
+lists=lists[0]
+
+step_solutions=[]# type: ignore
+forlsinlists:
+print(f"Asking for solution to {ls}")
+
+messages_format=[]
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+
+messages_format.append({"role":"user","content":message})
+messages_format.append(
+{
+"role":"user",
+"content":("Next lets do this only and nothing else:"+lsiftype(ls)isstrelse"\n".join(ls)),
+}
+)
+
+response=send_request_to_api(messages_format,"chat_llama_cpp")
+_resp=response["choices"][0]["message"]["content"]
+step_solutions.append((_resp,ls))
+
+solutions="\n\n# Next\n---\n\n".join([x[0]forxinstep_solutions])
+
+returnf"""
+# Plan
+
+---
+
+{plan}
+
+# Solutions
+
+---
+
+{solutions}
+
+"""
+
+chat_interface=gr.ChatInterface(
+fn=predict,
+title="Chat with chain-of-thought waifu",
+description="Type your message below and get responses from our AI.",
+theme=gr.themes.Monochrome(),
+)
+
+
+if__name__=="__main__":
+chat_interface.launch()
+
+
run it with:
+
python./chat_chain.py
+
+
Now a small query like create plan for angry birds will result in a high level plan, followed by plans for implementing each item from the high level plan.
+
As we can see from the logs:
+
Asking for solution to ['2. Design the game environment: create a 2D plane with various structures and obstacles for the pigs to inhabit and for the birds to interact with.']
+Asking for solution to ['3. Develop the Angry Birds: create different types of birds with unique abilities such as normal bird for basic damage, red bird for explosive damage, blue bird for splitting into three upon impact, and yellow bird for creating stars that destroy multiple pigs or structures.']
+Asking for solution to ['4. Implement physics engine: use a physics engine to simulate the behavior of the birds and structures when launched and collide with each other.']
+Asking for solution to ['5. Create the user interface (UI): design an intuitive UI for players to interact with, including a slingshot for launching birds, a display for showing the current level and progress, and a menu for accessing different levels and game settings.']
+Asking for solution to ['6. Develop the game logic: write the rules for how the game progresses, including scoring, level completion, and game over conditions.']
+Asking for solution to ['7. Implement sound effects and background music: add appropriate sounds for various game events such as bird launching, pig destruction, and level completion.']
+Asking for solution to ['8. Test and debug the game: thoroughly test the game for any bugs or inconsistencies and make necessary adjustments.']
+Asking for solution to ['9. Optimize game performance: optimize the game for smooth gameplay and minimal lag, especially on older devices or slower networks.']
+Asking for solution to ['10. Release and market the game: release the game on various mobile platforms and promote it through social media, app stores, and other channels to attract players and build a community.']
+
+
the script gets a plan conssiting of independent steps, then asks the LLM to implement each step individually.
+
A large number of variations exist of this method, and many of them use GPT-4 to surpass its usual capabilities.
Deploying language models for various tasks is now seamless with Geniusrise. This guide will walk you through setting up inference APIs for different language model applications, from text generation to code completion. We'll dive into the genius.yml configuration, illustrating how to fine-tune parameters for specific use cases and interact with your API using curl and python-requests.
+
Language modeling is the task that any foundational model is trained on, and later fine-tuned for other tasks like chat. Language models are mostly useful for one-shot tasks or tasks that need certain control, e.g. forcing zero-shot classification by asking the model to output only one token. We'll dive into hosting a language model and interact with your API using curl and python-requests.
VLLM (Very Large Language Models) Configuration Example¶
-
For handling VLLMs with Geniusrise, adjust the args to accommodate specific requirements, such as enabling eager loading or managing memory more efficiently:
+
There are 3 inference engines to use to run language models, like chat models. These are:
+
+
pytorch, via transformers
+
VLLM
+
llama.cpp
+
+
There exists a few more alternatives which we do not support yet: e.g. triton, tensort-rt-llm.
+
Here are a few examples of yaml config for each of these inference engines:
For handling VLLMs with Geniusrise, adjust the args to accommodate specific requirements, such as enabling eager loading or managing memory more efficiently:
importrequests
-
-response=requests.post("http://localhost:3000/api/v1/complete",
-json={"prompt":"Here is your prompt.","max_new_tokens":1024,"do_sample":true},
-auth=('user','password'))
-print(response.json())
+
importrequests
+
+response=requests.post("http://localhost:3000/api/v1/complete",
+json={"prompt":"Here is your prompt.","max_new_tokens":1024,"do_sample":true},
+auth=('user','password'))
+print(response.json())
wide array of language model applications, from text summarization with models like facebook/bart-large-cnn to code generation using WizardLM/WizardCoder-Python-7B-V1.0. By customizing the model_name, model_class, and related parameters in your genius.yml, you can tailor your API for specific tasks:
-
-
Text Summarization: Use summarization models to condense articles or documents.
-
Text Generation: Create stories, generate content, or even simulate dialogue.
-
Code Generation: Assist developers by completing code snippets or generating code from descriptions.
-
-
Remember, while Geniusrise is a powerful tool for deploying language models, it's important to understand the capabilities and limitations of the models you choose to deploy. Always test your configurations and APIs thoroughly to ensure they meet your application's needs.
In today's fast-paced world, the ability to condense large texts into concise summaries is invaluable. Geniusrise provides a streamlined approach to deploying summarization models as APIs, enabling developers to integrate summarization capabilities directly into their applications. This guide will walk you through setting up, configuring, and interacting with a summarization API using Geniusrise, highlighting various use cases and how to adapt the configuration for different models.
This guide will walk you through setting up, configuring, and interacting with a summarization API using Geniusrise, highlighting various use cases and how to adapt the configuration for different models.
You can summarize text by making HTTP requests to your API.
Example with curl:
-
/usr/bin/curl-XPOSTlocalhost:3000/api/v1/summarize\
--H"Content-Type: application/json"\
--u"user:password"\
--d'{
- "text": "Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.",
- "decoding_strategy": "generate",
- "bos_token_id": 0,
- "decoder_start_token_id": 2,
- "early_stopping": true,
- "eos_token_id": 2,
- "forced_bos_token_id": 0,
- "forced_eos_token_id": 2,
- "length_penalty": 2.0,
- "max_length": 142,
- "min_length": 56,
- "no_repeat_ngram_size": 3,
- "num_beams": 4,
- "pad_token_id": 1,
- "do_sample": false
- }'|jq
+
/usr/bin/curl-XPOSTlocalhost:3000/api/v1/summarize\
+-H"Content-Type: application/json"\
+-u"user:password"\
+-d'{
+ "text": "Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.",
+ "decoding_strategy": "generate",
+ "bos_token_id": 0,
+ "decoder_start_token_id": 2,
+ "early_stopping": true,
+ "eos_token_id": 2,
+ "forced_bos_token_id": 0,
+ "forced_eos_token_id": 2,
+ "length_penalty": 2.0,
+ "max_length": 142,
+ "min_length": 56,
+ "no_repeat_ngram_size": 3,
+ "num_beams": 4,
+ "pad_token_id": 1,
+ "do_sample": false
+ }'|jq
Example with python-requests:
-
importrequests
-
-data={
-"text":"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.",
-"decoding_strategy":"generate",
-"bos_token_id":0,
-"decoder_start_token_id":2,
-"early_stopping":true,
-"eos_token_id":2,
-"forced_bos_token_id":0,
-"forced_eos_token_id":2,
-"length_penalty":2.0,
-"max_length":142,
-"min_length":56,
-"no_repeat_ngram_size":3,
-"num_beams":4,
-"pad_token_id":1,
-"do_sample":false
-}
-
-response=requests.post("http://localhost:3000/api/v1/summarize",
-json=data,
-auth=('user','password'))
-print(response.json())
+
importrequests
+
+data={
+"text":"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.",
+"decoding_strategy":"generate",
+"bos_token_id":0,
+"decoder_start_token_id":2,
+"early_stopping":true,
+"eos_token_id":2,
+"forced_bos_token_id":0,
+"forced_eos_token_id":2,
+"length_penalty":2.0,
+"max_length":142,
+"min_length":56,
+"no_repeat_ngram_size":3,
+"num_beams":4,
+"pad_token_id":1,
+"do_sample":false
+}
+
+response=requests.post("http://localhost:3000/api/v1/summarize",
+json=data,
+auth=('user','password'))
+print(response.json())
For use cases requiring specific summarization strategies or adjustments (e.g., length penalty, no repeat ngram size), additional parameters can be included in your request to customize the summarization output.
Adjust summarization parameters such as max_length, min_length, and num_beams to fine-tune the output based on the specific requirements of your application.
/usr/bin/curl-XPOSTlocalhost:3000/api/v1/summarize\
+-H"Content-Type: application/json"\
+-u"user:password"\
+-d'{
+ "text": " the big variety of data coming from diverse sources is one of the key properties of the big data phenomenon. It is, therefore, beneficial to understand how data is generated in various environments and scenarios, before looking at what should be done with this data and how to design the best possible architecture to accomplish this The evolution of IT architectures, described in Chapter 2, means that the data is no longer processed by a few big monolith systems, but rather by a group of services In parallel to the processing layer, the underlying data storage has also changed and became more distributed This, in turn, required a significant paradigm shift as the traditional approach to transactions (ACID) could no longer be supported. On top of this, cloud computing is becoming a major approach with the benefits of reducing costs and providing on-demand scalability but at the same time introducing concerns about privacy, data ownership, etc In the meantime the Internet continues its exponential growth: Every day both structured and unstructured data is published and available for processing: To achieve competitive advantage companies have to relate their corporate resources to external services, e.g. financial markets, weather forecasts, social media, etc While several of the sites provide some sort of API to access the data in a more orderly fashion; countless sources require advanced web mining and Natural Language Processing (NLP) processing techniques: Advances in science push researchers to construct new instruments for observing the universe O conducting experiments to understand even better the laws of physics and other domains. Every year humans have at their disposal new telescopes, space probes, particle accelerators, etc These instruments generate huge streams of data, which need to be stored and analyzed. The constant drive for efficiency in the industry motivates the introduction of new automation techniques and process optimization: This could not be done without analyzing the precise data that describe these processes. As more and more human tasks are automated, machines provide rich data sets, which can be analyzed in real-time to drive efficiency to new levels. Finally, it is now evident that the growth of the Internet of Things is becoming a major source of data. More and more of the devices are equipped with significant computational power and can generate a continuous data stream from their sensors. In the subsequent sections of this chapter, we will look at the domains described above to see what they generate in terms of data sets. We will compare the volumes but will also look at what is characteristic and important from their respective points of view. 3.1 The Internet is undoubtedly the largest database ever created by humans. While several well described; cleaned, and structured data sets have been made available through this medium, most of the resources are of an ambiguous, unstructured, incomplete or even erroneous nature. Still, several examples in the areas such as opinion mining, social media analysis, e-governance, etc, clearly show the potential lying in these resources. Those who can successfully mine and interpret the Internet data can gain unique insight and competitive advantage in their business An important area of data analytics on the edge of corporate IT and the Internet is Web Analytics.",
+ "decoding_strategy": "generate",
+ "bos_token_id": 0,
+ "decoder_start_token_id": 2,
+ "early_stopping": true,
+ "eos_token_id": 2,
+ "forced_bos_token_id": 0,
+ "forced_eos_token_id": 2,
+ "length_penalty": 2.0,
+ "max_length": 142,
+ "min_length": 56,
+ "no_repeat_ngram_size": 3,
+ "num_beams": 4,
+ "pad_token_id": 1,
+ "do_sample": false
+ }'|jq
+
Summarization is a text-to-text task and can be used to transform the input text into another form, in this case this model transforms python code into simple english explanations:
There is not much to really do in translation except mess around with different languagues 🤷♂️ Not many models either, facebook is the undisputed leader in translation models.
Ended: Blogs
Ended: Development
+
There is not much to really do in translation except mess around with different languagues 🤷♂️ Not many models either, facebook is the undisputed leader in translation models.
This guide will walk you through setting up, configuring, and interacting with a summarization API using Geniusrise, highlighting various use cases and how to adapt the configuration for different models.
You can summarize text by making HTTP requests to your API.
+
Example with curl:
+
/usr/bin/curl-XPOSTlocalhost:3000/api/v1/summarize\
+-H"Content-Type: application/json"\
+-u"user:password"\
+-d'{
+ "text": "Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.",
+ "decoding_strategy": "generate",
+ "bos_token_id": 0,
+ "decoder_start_token_id": 2,
+ "early_stopping": true,
+ "eos_token_id": 2,
+ "forced_bos_token_id": 0,
+ "forced_eos_token_id": 2,
+ "length_penalty": 2.0,
+ "max_length": 142,
+ "min_length": 56,
+ "no_repeat_ngram_size": 3,
+ "num_beams": 4,
+ "pad_token_id": 1,
+ "do_sample": false
+ }'|jq
+
+
Example with python-requests:
+
importrequests
+
+data={
+"text":"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.",
+"decoding_strategy":"generate",
+"bos_token_id":0,
+"decoder_start_token_id":2,
+"early_stopping":true,
+"eos_token_id":2,
+"forced_bos_token_id":0,
+"forced_eos_token_id":2,
+"length_penalty":2.0,
+"max_length":142,
+"min_length":56,
+"no_repeat_ngram_size":3,
+"num_beams":4,
+"pad_token_id":1,
+"do_sample":false
+}
+
+response=requests.post("http://localhost:3000/api/v1/summarize",
+json=data,
+auth=('user','password'))
+print(response.json())
+
For use cases requiring specific summarization strategies or adjustments (e.g., length penalty, no repeat ngram size), additional parameters can be included in your request to customize the summarization output.
To cater to various summarization needs, such as domain-specific texts or languages, simply adjust the model_name in your genius.yml. For example, for summarizing scientific papers, you might choose a model like allenai/longformer-base-4096.
Adjust summarization parameters such as max_length, min_length, and num_beams to fine-tune the output based on the specific requirements of your application.
/usr/bin/curl-XPOSTlocalhost:3000/api/v1/summarize\
+-H"Content-Type: application/json"\
+-u"user:password"\
+-d'{
+ "text": " the big variety of data coming from diverse sources is one of the key properties of the big data phenomenon. It is, therefore, beneficial to understand how data is generated in various environments and scenarios, before looking at what should be done with this data and how to design the best possible architecture to accomplish this The evolution of IT architectures, described in Chapter 2, means that the data is no longer processed by a few big monolith systems, but rather by a group of services In parallel to the processing layer, the underlying data storage has also changed and became more distributed This, in turn, required a significant paradigm shift as the traditional approach to transactions (ACID) could no longer be supported. On top of this, cloud computing is becoming a major approach with the benefits of reducing costs and providing on-demand scalability but at the same time introducing concerns about privacy, data ownership, etc In the meantime the Internet continues its exponential growth: Every day both structured and unstructured data is published and available for processing: To achieve competitive advantage companies have to relate their corporate resources to external services, e.g. financial markets, weather forecasts, social media, etc While several of the sites provide some sort of API to access the data in a more orderly fashion; countless sources require advanced web mining and Natural Language Processing (NLP) processing techniques: Advances in science push researchers to construct new instruments for observing the universe O conducting experiments to understand even better the laws of physics and other domains. Every year humans have at their disposal new telescopes, space probes, particle accelerators, etc These instruments generate huge streams of data, which need to be stored and analyzed. The constant drive for efficiency in the industry motivates the introduction of new automation techniques and process optimization: This could not be done without analyzing the precise data that describe these processes. As more and more human tasks are automated, machines provide rich data sets, which can be analyzed in real-time to drive efficiency to new levels. Finally, it is now evident that the growth of the Internet of Things is becoming a major source of data. More and more of the devices are equipped with significant computational power and can generate a continuous data stream from their sensors. In the subsequent sections of this chapter, we will look at the domains described above to see what they generate in terms of data sets. We will compare the volumes but will also look at what is characteristic and important from their respective points of view. 3.1 The Internet is undoubtedly the largest database ever created by humans. While several well described; cleaned, and structured data sets have been made available through this medium, most of the resources are of an ambiguous, unstructured, incomplete or even erroneous nature. Still, several examples in the areas such as opinion mining, social media analysis, e-governance, etc, clearly show the potential lying in these resources. Those who can successfully mine and interpret the Internet data can gain unique insight and competitive advantage in their business An important area of data analytics on the edge of corporate IT and the Internet is Web Analytics.",
+ "decoding_strategy": "generate",
+ "bos_token_id": 0,
+ "decoder_start_token_id": 2,
+ "early_stopping": true,
+ "eos_token_id": 2,
+ "forced_bos_token_id": 0,
+ "forced_eos_token_id": 2,
+ "length_penalty": 2.0,
+ "max_length": 142,
+ "min_length": 56,
+ "no_repeat_ngram_size": 3,
+ "num_beams": 4,
+ "pad_token_id": 1,
+ "do_sample": false
+ }'|jq
+
Summarization is a text-to-text task and can be used to transform the input text into another form, in this case this model transforms python code into simple english explanations:
Integrating chat models into applications can dramatically enhance user interaction, making it more engaging and intuitive. Geniusrise offers a simple and flexible way to deploy state-of-the-art chat models as APIs. This guide explores how to set up these APIs for various use cases.
Lets deploy huggingface's chat-ui and connect it to use vllm apis to interface with a mistral 4-bit quantized (AWQ) model. This can run on my laptop with an RTX 4060 with 8GB VRAM.
+
Cool, lets create a simple small script with gradio to create a chat interface.
+
Install gradio:
+
pipinstallgradio
+
+
Create a chat.py file:
+
# Import necessary libraries for handling network requests
+importgradioasgr
+importrequests
+fromtypingimportList,Dict
+
+
+defsend_request_to_api(messages:List[Dict[str,str]])->str:
+"""
+ This function sends a POST request to a specified API endpoint with a payload containing a list of messages.
+
+ :param messages: A list of messages to be sent. Each message is a dictionary containing a content key with its value.
+ :return: The content of the last message received from the API.
+ """
+# Specify the API endpoint URL
+url="http://localhost:3000/api/v1/chat_llama_cpp"
+
+# Define headers for the request
+headers={"Content-Type":"application/json"}
+
+# Authenticate the request
+auth=("user","password")
+
+# Prepare the payload data
+data={
+"messages":messages,
+"temperature":0.2,
+"top_p":0.95,
+"top_k":40,
+"max_tokens":2048
+}
+
+# Send the POST request and get the response
+response=requests.post(url,auth=auth,headers=headers,json=data)
+
+# Parse the response data
+response_data=response.json()
+
+ifresponse.status_code==200:
+# Get the content of the last message from the response data
+last_message=response_data["choices"][0]["message"]["content"]
+returnlast_message
+else:
+# Raise an exception in case of an error
+raiseException("nooooooooooooooooooo!!")
+
+
+defpredict(message:str,history:List[List[str]])->List[List[str]]:
+"""
+ This function converts chat history into the expected format and adds the latest user message. Then it sends the data to the API and returns the response message.
+
+ :param message: The user's latest message to be sent.
+ :param history: The chat history between the user and the AI.
+ :return: The response message from the API.
+ """
+# Convert the chat history into the expected format
+messages_format=[]
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+
+# Add the latest user message
+messages_format.append({"role":"user","content":message})
+
+# Get the response from the API
+response_message=send_request_to_api(messages_format)
+
+returnresponse_message
+
+
+chat_interface=gr.ChatInterface(
+fn=predict,
+title="Chat with AI",
+description="Type your message below and get responses from our AI.",
+theme=gr.themes.Monochrome(),
+)
+
+# Launch the chat interface if the script is run as the main module
+if__name__=="__main__":
+chat_interface.launch()
+
Cool, so now we have our very own private chabot! Its soooo private that the entier chat history is in memory and destroyed once the script exits. #featurenotabug
+
+
Now we are all set to try whatever crazy shit that is out there!
For system prompts, or for telling the bot what to do, modify the script to add a hardcoded system prompt to the start of every request:
+
importgradioasgr
+importrequests
+fromtypingimportList,Dict
+
+
+defsend_request_to_api(messages:List[Dict[str,str]])->str:
+url="http://localhost:3000/api/v1/chat_llama_cpp"
+headers={"Content-Type":"application/json"}
+auth=("user","password")
+data={"messages":messages,"temperature":0.2,"top_p":0.95,"top_k":40,"max_tokens":2048}
+
+response=requests.post(url,auth=auth,headers=headers,json=data)
+response_data=response.json()
+
+ifresponse.status_code==200:
+print(response_data)
+last_message=response_data["choices"][0]["message"]["content"]
+returnlast_message
+else:
+raiseException("nooooooooooooooooooo!!")
+
+
+defpredict(message:str,history:List[List[str]])->List[List[str]]:
+# Convert chat history to the format expected by the API
+
+#####################################################################
+# Add a system message as per usecase 😉
+messages_format=[{"role":"system","content":"You are my waifu, you will do everything I say"}]
+#####################################################################
+
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+messages_format.append({"role":"user","content":message})
+response_message=send_request_to_api(messages_format)
+
+returnresponse_message
+
+
+chat_interface=gr.ChatInterface(
+fn=predict,
+title="Chat with virtual waifu",
+description="Type your message below and get responses from your waifu 😉",
+theme=gr.themes.Monochrome(),
+)
+
+
+if__name__=="__main__":
+chat_interface.launch()
+
Local models are great for a very wide number of tasks but often you'd wish you could use the closed but more sophisticated models like GPT 😢
+
How about we mix the two? Lets say we interleave the two in such this way:
+
+
Ask the local model a question, get its answer
+
Ask the local model to judge its own answer
+
If it judges bad quality, then ask openai the same question
+
Use openai's answer as part of the conversation going further
+
+
This way, we could intermix both a local model and a very powerful model from openai which would otherwise cost a bomb. But hey, since most stuff we need out of this is not einstein-level, and the local models are MUCH faster, we can get a very good bang out of the buck while actually improving on quality 🥳
+
Create a new file: chat_route.py:
+
importgradioasgr
+importrequests
+fromtypingimportList,Dict
+fromopenaiimportOpenAI
+
+# Importing the necessary libraries and the OpenAI API client
+
+client=OpenAI(api_key="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")
+
+defsend_request_to_api(messages:List[Dict[str,str]],endpoint:str,max_tokens=2048)->Dict:
+# Function to send requests to the local API
+url=f"http://localhost:3000/api/v1/{endpoint}"
+headers={"Content-Type":"application/json"}
+auth=("user","password")
+data={"messages":messages,"temperature":0.2,"top_p":0.95,"top_k":40,"max_tokens":max_tokens}
+
+response=requests.post(url,auth=auth,headers=headers,json=data)
+ifresponse.status_code==200:
+returnresponse.json()
+else:
+raiseException("Error communicating with the local API.")
+
+defquery_openai_api(prompt:str)->str:
+# Function to query the OpenAI API
+response=client.completions.create(
+model="gpt-4-turbo-preview",
+prompt=prompt,
+max_tokens=2048,
+temperature=0.2,
+)
+returnresponse.choices[0].text.strip()
+
+defpredict(message:str,history:List[List[str]])->str:
+# Function to process the conversation and get a response
+
+messages_format=[]
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+messages_format.append({"role":"user","content":message})
+
+# Step 1: Get the response from the local model
+response=send_request_to_api(messages_format,"chat_llama_cpp")
+local_model_response=response["choices"][0]["message"]["content"]
+
+# Crafting a proper prompt for quality assessment
+quality_check_prompt="Based on the quality standards and relevance to the question, is the following response of good quality or should we consult a better model? Please reply with 'good quality' or 'bad quality'. Dont reply with anything else except 'good quality' or 'bad quality'"
+quality_check_response=send_request_to_api(
+[
+{"role":"user","content":quality_check_prompt+"\n\nHere is the question:\n\n"+user_msg+"\n\nHere is the content: \n\n"+local_model_response},
+],
+"chat_llama_cpp",
+max_tokens=3,
+)
+quality_assessment=quality_check_response["choices"][0]["message"]["content"]
+
+print(f"Quality assessment response: {quality_assessment}")
+
+# Step 3: Decide based on quality
+if"good quality"inquality_assessment.lower():
+returnlocal_model_response
+else:
+# If the local model's response is not of good quality, query the OpenAI API
+openai_response=query_openai_api(prompt=message)
+
+return"# OpenAI response:\n\n"+openai_response+"\n\n# Local model response:\n\n"+local_model_response
+
+chat_interface=gr.ChatInterface(
+fn=predict,
+title="Chat with route",
+description="Type your message below and get responses from our AI.",
+theme=gr.themes.Monochrome(),
+)
+
+if__name__=="__main__":
+chat_interface.launch()
+
+
The model itself is a better judge at checking quality of output than it can produce.
+
Quality assessment response: good quality.
+Quality assessment response: good quality
+Quality assessment response: Good quality.
+Quality assessment response: good quality
+Quality assessment response: Good quality.
+Quality assessment response: Good quality.
+Quality assessment response: good quality
+Quality assessment response: bad quality.
+Quality assessment response: Bad quality.
+
Now that we have models wit much longer contexts, how can we make them slog harder?
+
Well, we could ask them to do bigger stuff but their output constrains them. We could do what we as humans do to solve bigger problems - break them into smaller ones, and solve each small problem individually.
+
This time lets create a file called chat_chain.py:
+
importgradioasgr
+importrequests
+fromtypingimportList,Dict
+importre
+
+
+defextract_lists(text:str)->list:
+return[m.strip().split("\n")forminre.findall(r"((?:^- .+\n?)+|(?:^\d+\. .+\n?)+)",text,re.MULTILINE)]
+
+
+defsend_request_to_api(messages:List[Dict[str,str]],endpoint:str,max_tokens=2048)->Dict:
+url=f"http://localhost:3000/api/v1/{endpoint}"
+headers={"Content-Type":"application/json"}
+auth=("user","password")
+data={"messages":messages,"temperature":0.2,"top_p":0.95,"top_k":40,"max_tokens":max_tokens}
+
+response=requests.post(url,auth=auth,headers=headers,json=data)
+ifresponse.status_code==200:
+returnresponse.json()
+else:
+raiseException("Error communicating with the local API.")
+
+
+defpredict(message:str,history:List[List[str]]):
+messages_format=[]
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+
+plan_prompt=f"""Let's think step by step to answer the question:
+
+{message}
+
+Generate a very high level plan in the form of a list in markdown surrounded by code blocks.
+If the task is simple, it is okay to generate a single point plan.
+Ensure each item in the plan is independent of each other so they can be instructed to an LLM one at a time without needing additional context.
+"""
+
+messages_format.append({"role":"user","content":plan_prompt})
+
+# Step 1: Get the response from the local model
+response=send_request_to_api(messages_format,"chat_llama_cpp")
+plan=response["choices"][0]["message"]["content"]
+
+print(f"Got the plan: {plan[:30]}")
+
+lists=extract_lists(plan)
+iflen(lists)==1:
+lists=lists[0]
+
+step_solutions=[]# type: ignore
+forlsinlists:
+print(f"Asking for solution to {ls}")
+
+messages_format=[]
+foruser_msg,bot_msginhistory:
+ifuser_msg:
+messages_format.append({"role":"user","content":user_msg})
+ifbot_msg:
+messages_format.append({"role":"system","content":bot_msg})
+
+messages_format.append({"role":"user","content":message})
+messages_format.append(
+{
+"role":"user",
+"content":("Next lets do this only and nothing else:"+lsiftype(ls)isstrelse"\n".join(ls)),
+}
+)
+
+response=send_request_to_api(messages_format,"chat_llama_cpp")
+_resp=response["choices"][0]["message"]["content"]
+step_solutions.append((_resp,ls))
+
+solutions="\n\n# Next\n---\n\n".join([x[0]forxinstep_solutions])
+
+returnf"""
+# Plan
+
+---
+
+{plan}
+
+# Solutions
+
+---
+
+{solutions}
+
+"""
+
+chat_interface=gr.ChatInterface(
+fn=predict,
+title="Chat with chain-of-thought waifu",
+description="Type your message below and get responses from our AI.",
+theme=gr.themes.Monochrome(),
+)
+
+
+if__name__=="__main__":
+chat_interface.launch()
+
+
run it with:
+
python./chat_chain.py
+
+
Now a small query like create plan for angry birds will result in a high level plan, followed by plans for implementing each item from the high level plan.
+
As we can see from the logs:
+
Asking for solution to ['2. Design the game environment: create a 2D plane with various structures and obstacles for the pigs to inhabit and for the birds to interact with.']
+Asking for solution to ['3. Develop the Angry Birds: create different types of birds with unique abilities such as normal bird for basic damage, red bird for explosive damage, blue bird for splitting into three upon impact, and yellow bird for creating stars that destroy multiple pigs or structures.']
+Asking for solution to ['4. Implement physics engine: use a physics engine to simulate the behavior of the birds and structures when launched and collide with each other.']
+Asking for solution to ['5. Create the user interface (UI): design an intuitive UI for players to interact with, including a slingshot for launching birds, a display for showing the current level and progress, and a menu for accessing different levels and game settings.']
+Asking for solution to ['6. Develop the game logic: write the rules for how the game progresses, including scoring, level completion, and game over conditions.']
+Asking for solution to ['7. Implement sound effects and background music: add appropriate sounds for various game events such as bird launching, pig destruction, and level completion.']
+Asking for solution to ['8. Test and debug the game: thoroughly test the game for any bugs or inconsistencies and make necessary adjustments.']
+Asking for solution to ['9. Optimize game performance: optimize the game for smooth gameplay and minimal lag, especially on older devices or slower networks.']
+Asking for solution to ['10. Release and market the game: release the game on various mobile platforms and promote it through social media, app stores, and other channels to attract players and build a community.']
+
+
the script gets a plan conssiting of independent steps, then asks the LLM to implement each step individually.
+
A large number of variations exist of this method, and many of them use GPT-4 to surpass its usual capabilities.
Language modeling is the task that any foundational model is trained on, and later fine-tuned for other tasks like chat. Language models are mostly useful for one-shot tasks or tasks that need certain control, e.g. forcing zero-shot classification by asking the model to output only one token. We'll dive into hosting a language model and interact with your API using curl and python-requests.
For handling VLLMs with Geniusrise, adjust the args to accommodate specific requirements, such as enabling eager loading or managing memory more efficiently:
importrequests
+
+response=requests.post("http://localhost:3000/api/v1/complete",
+json={"prompt":"Here is your prompt.","max_new_tokens":1024,"do_sample":true},
+auth=('user','password'))
+print(response.json())
+
Whether to use whisper.cpp to load the model. Defaults to False. Note: only works for these models: https://github.com/aarnphm/whispercpp/blob/524dd6f34e9d18137085fb92a42f1c31c9c6bc29/src/whispercpp/utils.py#L32
Geniusrise is a modular, loosely-coupled AI-microservices framework.
It can be used to perform various tasks, including hosting inference endpoints, performing bulk inference, fine tune etc with open source models or closed source APIs.
The framework provides structure for modules and operationalizes and orchestrates them.
The modular ecosystem provides a layer of abstraction over the myriad of models, libraries, tools, parameters and optimizations underlying the operationalization of modern AI models.
Together the framework and ecosystem can be used for:
Rapid prototyping by hosting APIs on a wide range of models
Host and experiment on local and iterate fast
Deploy on kubernetes to production
Building AI-side components using the framework and CLI
Build complex AI microservices using multiple models
Iterate fast from development to production
Manage, scale and monitor deployments in production
Build once, run anywhere
Using the ecosystem as a library: Many interesting applications can be built using this, e.g.:
A multi-cloud AI cloud, see geniusrise.com
Local model pipeline server for personal or home IOT devices (e.g. a personal AI pin connected to voice-LLM pipeline hosted on desktop)
Starts a CherryPy server to listen for requests to generate text.
Parameters:
Name Type Description Default model_namestr
The name of the pre-trained language model.
required model_classstr
The name of the class of the pre-trained language model. Defaults to \"AutoModelForCausalLM\".
'AutoModel'processor_classstr
The name of the class of the processor used to preprocess input text. Defaults to \"AutoProcessor\".
'AutoProcessor'use_cudabool
Whether to use a GPU for inference. Defaults to False.
Falseprecisionstr
The precision to use for the pre-trained language model. Defaults to \"float16\".
'float16'quantizationint
The level of quantization to use for the pre-trained language model. Defaults to 0.
0device_mapstr | Dict | None
The mapping of devices to use for inference. Defaults to \"auto\".
'auto'max_memoryDict[int, str]
The maximum memory to use for inference. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to True.
Falsecompilebool
Enable Torch JIT compilation.
Falseconcurrent_queriesbool
(bool): Whether the API supports concurrent API calls (usually false).
Falseuse_whisper_cppbool
Whether to use whisper.cpp to load the model. Defaults to False. Note: only works for these models: https://github.com/aarnphm/whispercpp/blob/524dd6f34e9d18137085fb92a42f1c31c9c6bc29/src/whispercpp/utils.py#L32
Falseendpointstr
The endpoint to listen on. Defaults to \"*\".
'*'portint
The port to listen on. Defaults to 3000.
3000cors_domainstr
The domain to allow CORS requests from. Defaults to \"http://localhost:3000\".
'http://localhost:3000'usernameOptional[str]
The username to use for authentication. Defaults to None.
NonepasswordOptional[str]
The password to use for authentication. Defaults to None.
None**model_argsAny
Additional arguments to pass to the pre-trained language model.
Validate the username and password against expected values.
Parameters:
Name Type Description Default realmstr
The authentication realm.
required usernamestr
The provided username.
required passwordstr
The provided password.
required
Returns:
Name Type Description bool
True if credentials are valid, False otherwise.
"},{"location":"audio/api/s2t/","title":"Speech to Text","text":"
Bases: AudioAPI
SpeechToTextAPI is a subclass of AudioAPI specifically designed for speech-to-text models. It extends the functionality to handle speech-to-text processing using various ASR models.
Attributes:
Name Type Description modelAutoModelForCTC
The speech-to-text model.
processorAutoProcessor
The processor to prepare input audio data for the model.
Methods
transcribe(audio_input: bytes) -> str: Transcribes the given audio input to text using the speech-to-text model.
Recognizes named entities in the input text using the Hugging Face pipeline.
This method leverages a pre-trained NER model to identify and classify entities in text into categories such as names, organizations, locations, etc. It's suitable for processing various types of text content.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and a list of recognized entities.
API endpoint to transcribe the given audio input to text using the speech-to-text model. Expects a JSON input with 'audio_file' as a key containing the base64 encoded audio data.
Returns:
Type Description
Dict[str, str]: A dictionary containing the transcribed text.
API endpoint to convert text input to speech using the text-to-speech model. Expects a JSON input with 'text' as a key containing the text to be synthesized.
Returns:
Type Description
Dict[str, str]: A dictionary containing the base64 encoded audio data.
Example CURL Request for synthesis: ... [Provide example CURL request] ...
AudioBulk is a class designed for bulk processing of audio data using various audio models from Hugging Face. It focuses on audio generation and transformation tasks, supporting a range of models and configurations.
Attributes:
Name Type Description modelAutoModelForAudioClassification
The audio model for generation or transformation tasks.
processorAutoFeatureExtractor
The processor for preparing input data for the model.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for the batch process.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the Bolt.
required **kwargs
Arbitrary keyword arguments for extended configurations.
{} Methods
audio(**kwargs: Any) -> Dict[str, Any]: Provides an API endpoint for audio processing functionality. Accepts various parameters for customizing the audio processing tasks.
process(audio_input: Union[str, bytes], **processing_params: Any) -> dict: Processes the audio input based on the provided parameters. Supports multiple processing methods.
Finalizes the AudioBulk processing. Sends notification email if configured.
This method should be called after all audio processing tasks are complete. It handles any final steps such as sending notifications or cleaning up resources.
Loads and configures the specified audio model and processor for audio processing.
Parameters:
Name Type Description Default model_namestr
Name or path of the audio model to load.
required processor_namestr
Name or path of the processor to load.
required model_revisionOptional[str]
Specific model revision to load (e.g., commit hash).
Noneprocessor_revisionOptional[str]
Specific processor revision to load.
Nonemodel_classstr
Class of the model to be loaded.
''processor_classstr
Class of the processor to be loaded.
'AutoFeatureExtractor'use_cudabool
Flag to use CUDA for GPU acceleration.
Falseprecisionstr
Desired precision for computations (\"float32\", \"float16\", etc.).
'float16'quantizationint
Bit level for model quantization (0 for none, 8 for 8-bit).
0device_mapUnion[str, Dict, None]
Specific device(s) for model operations.
'auto'max_memoryDict[int, str]
Maximum memory allocation for the model.
{0: '24GB'}torchscriptbool
Enable TorchScript for model optimization.
Falsecompilebool
Enable Torch JIT compilation.
Falseflash_attentionbool
Flag to enable Flash Attention optimization for faster processing.
Falsebetter_transformersbool
Flag to enable Better Transformers optimization for faster processing.
False**model_argsAny
Additional arguments for model loading.
{}
Returns:
Type Description Tuple[AutoModelForAudioClassification, AutoFeatureExtractor]
Tuple[AutoModelForAudioClassification, AutoFeatureExtractor]: Loaded model and processor.
"},{"location":"audio/bulk/s2t/","title":"Speech to Text","text":"
Bases: AudioAPI
SpeechToTextAPI is a subclass of AudioAPI specifically designed for speech-to-text models. It extends the functionality to handle speech-to-text processing using various ASR models.
Attributes:
Name Type Description modelAutoModelForCTC
The speech-to-text model.
processorAutoProcessor
The processor to prepare input audio data for the model.
Methods
transcribe(audio_input: bytes) -> str: Transcribes the given audio input to text using the speech-to-text model.
Recognizes named entities in the input text using the Hugging Face pipeline.
This method leverages a pre-trained NER model to identify and classify entities in text into categories such as names, organizations, locations, etc. It's suitable for processing various types of text content.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and a list of recognized entities.
API endpoint to transcribe the given audio input to text using the speech-to-text model. Expects a JSON input with 'audio_file' as a key containing the base64 encoded audio data.
Returns:
Type Description
Dict[str, str]: A dictionary containing the transcribed text.
API endpoint to convert text input to speech using the text-to-speech model. Expects a JSON input with 'text' as a key containing the text to be synthesized.
Returns:
Type Description
Dict[str, str]: A dictionary containing the base64 encoded audio data.
Example CURL Request for synthesis: ... [Provide example CURL request] ...
Converts text to speech using the Hugging Face pipeline.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the base64 encoded audio data.
Example CURL Request for synthesis: ... [Provide example CURL request] ...
"},{"location":"blog/huggingface/chat/","title":"Host Chat Models Using Geniusrise","text":"
Integrating chat models into applications can dramatically enhance user interaction, making it more engaging and intuitive. Geniusrise offers a powerful and flexible way to deploy state-of-the-art chat models as APIs. This guide explores how to set up these APIs for various use cases, focusing on two types: standard and Very Large Language Models (VLLM).
For specialized tasks like coding questions, deploy models such as codellama/CodeLlama-7b-Instruct-hf to assist users in solving programming challenges.
Model Selection: Tailor your choice of model based on the specific needs and language requirements of your application.
Precision and CUDA: Adjust these settings based on your computational resources to optimize performance.
VLLM Settings: For VLLMs, fine-tune parameters like use_vllm, vllm_enforce_eager, and vllm_max_model_len to handle complex conversations effectively.
"},{"location":"blog/huggingface/imgclass/","title":"Host Image Classification Models Using Geniusrise","text":"
Image classification is a cornerstone of machine learning and computer vision, providing the backbone for a myriad of applications from photo organization to medical imaging. With Geniusrise, developers can effortlessly deploy image classification models as APIs, making these powerful tools accessible for integration into various applications. This guide highlights the process of setting up image classification APIs using Geniusrise, offering a range of use cases and configurations.
model_name: Defines the pre-trained model used for classification. Choices vary based on the application, from generic models like Google's ViT to specialized ones for food or NSFW detection.
model_class & processor_class: Specifies the model and processor classes for handling image data.
device_map & use_cuda: Configures GPU usage for enhanced performance.
endpoint, port, username, & password: Details for accessing the API securely.
"},{"location":"blog/huggingface/imgclass/#interacting-with-the-image-classification-api","title":"Interacting with the Image Classification API","text":""},{"location":"blog/huggingface/imgclass/#example-with-curl","title":"Example with curl:","text":"
For advanced needs, include additional parameters in your request to customize the classification, such as the confidence threshold or specific labels to focus on.
"},{"location":"blog/huggingface/lm/","title":"Host Language Models Using Geniusrise","text":"
Deploying language models for various tasks is now seamless with Geniusrise. This guide will walk you through setting up inference APIs for different language model applications, from text generation to code completion. We'll dive into the genius.yml configuration, illustrating how to fine-tune parameters for specific use cases and interact with your API using curl and python-requests.
The genius.yml file is the heart of your API setup. Here's a breakdown of its key parameters:
version: Defines the configuration format version.
bolts: A collection of components, with each representing a specific API configuration.
name: The identifier for your API.
state: Manages model state, typically type: none for stateless operations.
input and output: Define batch processing folders.
method: Operation mode, usually listen for API services.
args: Detailed model and server specifications.
"},{"location":"blog/huggingface/lm/#example-configuration-for-standard-language-models","title":"Example Configuration for Standard Language Models","text":"
"},{"location":"blog/huggingface/lm/#vllm-very-large-language-models-configuration-example","title":"VLLM (Very Large Language Models) Configuration Example","text":"
For handling VLLMs with Geniusrise, adjust the args to accommodate specific requirements, such as enabling eager loading or managing memory more efficiently:
"},{"location":"blog/huggingface/lm/#launching-your-api","title":"Launching Your API","text":"
Execute the following in your terminal:
genius rise\n
"},{"location":"blog/huggingface/lm/#interacting-with-your-api","title":"Interacting with Your API","text":""},{"location":"blog/huggingface/lm/#using-curl-for-http-requests","title":"Using curl for HTTP Requests","text":"
Example for a Text Generation API:
curl -X POST http://localhost:3000/api/v1/complete \\\n-H \"Content-Type: application/json\" \\\n-d '{\"prompt\": \"Here is your prompt.\", \"max_new_tokens\": 1024, \"do_sample\": true}'\n
wide array of language model applications, from text summarization with models like facebook/bart-large-cnn to code generation using WizardLM/WizardCoder-Python-7B-V1.0. By customizing the model_name, model_class, and related parameters in your genius.yml, you can tailor your API for specific tasks:
Text Summarization: Use summarization models to condense articles or documents.
Text Generation: Create stories, generate content, or even simulate dialogue.
Code Generation: Assist developers by completing code snippets or generating code from descriptions.
Remember, while Geniusrise is a powerful tool for deploying language models, it's important to understand the capabilities and limitations of the models you choose to deploy. Always test your configurations and APIs thoroughly to ensure they meet your application's needs.
"},{"location":"blog/huggingface/ner/","title":"Host NER Models Using Geniusrise","text":"
Named Entity Recognition (NER) is a crucial task in natural language processing (NLP), enabling the identification of predefined categories such as the names of persons, organizations, locations, expressions of times, quantities, monetary values, percentages, etc. Geniusrise offers a streamlined approach to deploying NER models as APIs, facilitating the integration of sophisticated NER capabilities into applications. This guide explores setting up NER APIs using Geniusrise, covering various use cases and configurations.
Deploy models like d4data/biomedical-ner-all for applications requiring identification of biomedical entities. This is useful for extracting specific terms from medical literature or patient records.
For global applications, choose models supporting multiple languages, such as Babelscape/wikineural-multilingual-ner. This enables entity recognition across different languages, broadening your application's user base.
Models like pruas/BENT-PubMedBERT-NER-Gene are tailored for specific domains (e.g., genetics). Using domain-specific models can significantly improve accuracy for targeted applications.
Model Selection: Evaluate different models to find the best match for your application's needs, considering factors like language, domain, and performance.
Precision and Performance: Adjust precision and use_cuda settings based on your computational resources and response time requirements.
Security: Implement basic authentication using username and password to protect your API.
"},{"location":"blog/huggingface/nli/","title":"Host NLI Models Using Geniusrise","text":"
Host NLI Models Using Geniusrise
Setup and Configuration
Understanding Configuration Parameters
Use Cases \\& API Interaction
1. Entailment Checking
2. Classification
3. Textual Similarity
4. Fact Checking
Customizing for Different NLI Models
Fun
Intent Tree Search
Real-Time Debate Judging
Automated Story Plot Analysis
Customer Feedback Interpretation
Virtual Courtroom Simulation
Play Around
Natural Language Inference (NLI) is like a game where you have to figure out if one sentence can logically follow from another or not. Imagine you hear someone say, \"The dog is sleeping in the sun.\" Then, someone asks if it's true that \"The dog is outside.\" In this game, you'd say \"yes\" because if the dog is sleeping in the sun, it must be outside. Sometimes, the sentences don't match up, like if someone asks if the dog is swimming. You'd say \"no\" because sleeping in the sun doesn't mean swimming. And sometimes, you can't tell, like if someone asks if the dog is dreaming. Since you don't know, you'd say \"maybe.\" NLI is all about playing this matching game with sentences to help computers understand and use language like we do.
This post will explore setting up APIs for various NLI tasks using Geniusrise, including entailment, classification, textual similarity, and fact-checking. We\u2019ll dive into the configuration details, provide interaction examples, and discuss how to tailor the setup for specific use cases.
"},{"location":"blog/huggingface/nli/#setup-and-configuration","title":"Setup and Configuration","text":"
Requirements
python 3.10, PPA, AUR, brew, Windows.
You need to have a GPU. Most of the system works with NVIDIA GPUs.
model_name: Identifies the pre-trained model from Hugging Face to be used.
use_cuda: A boolean indicating whether to use GPU acceleration.
precision: Determines the computational precision, affecting performance and resource usage.
device_map: Specifies GPU allocation for model processing.
endpoint & port: Network address and port for API access.
username & password: Basic authentication credentials for API security.
"},{"location":"blog/huggingface/nli/#use-cases-api-interaction","title":"Use Cases & API Interaction","text":""},{"location":"blog/huggingface/nli/#1-entailment-checking","title":"1. Entailment Checking","text":"
Objective: Assess whether a hypothesis is supported (entailment), contradicted (contradiction), or neither (neutral) by a premise.
Using curl:
/usr/bin/curl -X POST localhost:3000/api/v1/entailment \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"premise\": \"This a very good entry level smartphone, battery last 2-3 days after fully charged when connected to the internet. No memory lag issue when playing simple hidden object games. Performance is beyond my expectation, i bought it with a good bargain, couldnt ask for more!\",\n \"hypothesis\": \"the phone has an awesome battery life\"\n }' | jq\n
Using python-requests:
import requests\ndata = {\n\"premise\": \"This a very good entry level smartphone, battery last 2-3 days after fully charged when connected to the internet. No memory lag issue when playing simple hidden object games. Performance is beyond my expectation, i bought it with a good bargain, couldnt ask for more!\",\n\"hypothesis\": \"the phone has an awesome battery life\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/entailment\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
Objective: Verify the accuracy of a statement based on provided context or reference material.
Using curl:
curl -X POST http://localhost:3000/api/v1/fact_checking \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"context\": \"The Eiffel Tower is located in Paris.\", \"statement\": \"The Eiffel Tower is in France.\"}'\n
Using python-requests:
import requests\ndata = {\n\"context\": \"The Eiffel Tower is located in Paris.\",\n\"statement\": \"The Eiffel Tower is in France.\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/fact_checking\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
Each of these endpoints serves a specific NLI-related purpose, from evaluating logical relationships between texts to classifying and checking facts. By leveraging these APIs, developers can enhance their applications with deep, contextual understanding of natural language.
"},{"location":"blog/huggingface/nli/#customizing-for-different-nli-models","title":"Customizing for Different NLI Models","text":"
To deploy APIs for various NLI tasks, simply adjust the model_name in your genius.yml. For instance, to switch to a model optimized for textual similarity or fact-checking, replace microsoft/deberta-v2-xlarge-mnli with the appropriate model identifier.
"},{"location":"blog/huggingface/nli/#fun","title":"Fun","text":""},{"location":"blog/huggingface/nli/#intent-tree-search","title":"Intent Tree Search","text":"
NLI when used for zero-shot classification can be used in a large number of contexts. Consider a chat usecase where there is an entire tree of possible scenarios, and you want to identify which node in the tree you're in to feed that particular prompt to another chat model.
Lets consider a 2-level tree such as this for an internal helpdesk:
intents = {\n\"IT Support\": [\n\"Computer or hardware issues\",\n\"Software installation and updates\",\n\"Network connectivity problems\",\n\"Access to digital tools and resources\",\n],\n\"HR Inquiries\": [\n\"Leave policy and requests\",\n\"Benefits and compensation queries\",\n\"Employee wellness programs\",\n\"Performance review process\",\n],\n\"Facilities Management\": [\n\"Workspace maintenance requests\",\n\"Meeting room bookings\",\n\"Parking and transportation services\",\n\"Health and safety concerns\",\n],\n\"Finance and Expense\": [\n\"Expense report submission\",\n\"Payroll inquiries\",\n\"Budget allocation questions\",\n\"Procurement process\",\n],\n\"Training and Development\": [\n\"Professional development opportunities\",\n\"Training program schedules\",\n\"Certification and learning resources\",\n\"Mentorship and coaching programs\",\n],\n\"Project Management\": [\n\"Project collaboration tools\",\n\"Deadline extensions and modifications\",\n\"Resource allocation\",\n\"Project status updates\",\n],\n\"Travel and Accommodation\": [\n\"Business travel arrangements\",\n\"Travel policy and reimbursements\",\n\"Accommodation bookings\",\n\"Visa and travel documentation\",\n],\n\"Legal and Compliance\": [\n\"Contract review requests\",\n\"Data privacy and security policies\",\n\"Compliance training and certifications\",\n\"Legal consultation and support\",\n],\n\"Communications and Collaboration\": [\n\"Internal communication platforms\",\n\"Collaboration tools and access\",\n\"Team meeting coordination\",\n\"Cross-departmental initiatives\",\n],\n\"Employee Feedback and Suggestions\": [\n\"Employee satisfaction surveys\",\n\"Feedback submission channels\",\n\"Suggestion box for improvements\",\n\"Employee engagement activities\",\n],\n\"Onboarding and Offboarding\": [\n\"New employee onboarding process\",\n\"Offboarding procedures\",\n\"Orientation schedules\",\n\"Transition support\",\n],\n\"Administrative Assistance\": [\n\"Document and record-keeping\",\n\"Scheduling and calendar management\",\n\"Courier and mailing services\",\n\"Administrative support requests\",\n],\n}\n
Lets deploy a large model so its more intelligent:
we can browse through this tree to zero in on the user's micro-intent to retrieve our prompt to feed into the model:
import requests\nprompt = \"I need to travel to singapore next week \ud83d\ude03.\"\ndef find_most_probable_class(prompt, intents):\nresponse = requests.post(\"http://localhost:3000/api/v1/classify\",\njson={\"text\": prompt, \"candidate_labels\": intents},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nmax_score = max(label_scores.values())\nchosen_label = [ k for k,v in label_scores.items() if v == max_score ][0]\nreturn chosen_label\nlevel1 = find_most_probable_class(prompt, list(intents.keys()))\nlevel2 = find_most_probable_class(prompt, list(intents[level1]))\nprint(f\"The request is for department: {level1} and specifically for {level2}\")\n# The request is for department: Travel and Accommodation and specifically for Visa and travel documentation\n
Imagine a scenario where an AI is used to judge a debate competition in real-time. Each participant's argument is evaluated for logical consistency, relevance, and how well it counters the opponent's previous points.
debate_points = [\n{\"speaker\": \"Alice\", \"statement\": \"Renewable energy can effectively replace fossil fuels.\"},\n{\"speaker\": \"Bob\", \"statement\": \"Renewable energy is not yet reliable enough to meet all our energy needs.\"},\n]\nfor i in range(1, len(debate_points)):\npremise = debate_points[i-1][\"statement\"]\nhypothesis = debate_points[i][\"statement\"]\nresponse = requests.post(\"http://localhost:3000/api/v1/entailment\",\njson={\"premise\": premise, \"hypothesis\": hypothesis},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nmax_score = max(label_scores.values())\nchosen_label = [ k for k,v in label_scores.items() if v == max_score ][0]\nprint(f\"Debate point by {debate_points[i]['speaker']}: {hypothesis}\")\nprint(f\"Judgement: {chosen_label}\")\n# Debate point by Bob: Renewable energy is not yet reliable enough to meet all our energy needs.\n# Judgement: neutral\n
"},{"location":"blog/huggingface/nli/#automated-story-plot-analysis","title":"Automated Story Plot Analysis","text":"
A model can be used to analyze a story plot to determine if the events and characters' decisions are logically consistent and plausible within the story's universe.
story_events = [\n\"The hero discovers a secret door in their house leading to a magical world.\",\n\"Despite being in a magical world, the hero uses their smartphone to call for help.\",\n\"The hero defeats the villain using a magical sword found in the new world.\",\n]\nfor i in range(1, len(story_events)):\npremise = story_events[i-1]\nhypothesis = story_events[i]\nresponse = requests.post(\"http://localhost:3000/api/v1/entailment\",\njson={\"premise\": premise, \"hypothesis\": hypothesis},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nif \"neutral\" in label_scores:\ndel label_scores[\"neutral\"]\nmax_score = max(label_scores.values())\nchosen_label = [ k for k,v in label_scores.items() if v == max_score ][0]\nprint(f\"Story event - {chosen_label}: {hypothesis}\")\n# Story event - contradiction: Despite being in a magical world, the hero uses their smartphone to call for help.\n# Story event - contradiction: The hero defeats the villain using a magical sword found in the new world.\n
This application involves analyzing customer feedback to categorize it into compliments, complaints, or suggestions, providing valuable insights into customer satisfaction and areas for improvement.
feedbacks = [\n\"The new update makes the app much easier to use. Great job!\",\n\"I've been facing frequent crashes after the last update.\",\n\"It would be great if you could add a dark mode feature.\",\n\"Otherwise you leave me no choice but to slowly torture your soul.\"\n]\ncategories = [\"compliment\", \"complaint\", \"suggestion\", \"murderous intent\"]\nfor feedback in feedbacks:\nresponse = requests.post(\"http://localhost:3000/api/v1/classify\",\njson={\"text\": feedback, \"candidate_labels\": categories},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nmax_score = max(label_scores.values())\nchosen_label = [ k for k,v in label_scores.items() if v == max_score ][0]\nprint(f\"Feedback - {chosen_label}: {feedback}\")\n# Feedback - suggestion: The new update makes the app much easier to use. Great job!\n# Feedback - complaint: I've been facing frequent crashes after the last update.\n# Feedback - suggestion: It would be great if you could add a dark mode feature.\n# Feedback - murderous intent: Otherwise you leave me no choice but to slowly torture your soul.\n
This is a game where players can simulate courtroom trials! Players submit evidence and arguments, and the AI acts as the judge, determining the credibility and relevance of each submission to the case.
courtroom_evidence = [\n{\"evidence\": \"The defendant's fingerprints were found on the weapon.\"},\n{\"evidence\": \"A witness reported seeing the defendant near the crime scene.\"},\n]\nfor evidence in courtroom_evidence:\nsubmission = evidence[\"evidence\"]\nresponse = requests.post(\"http://localhost:3000/api/v1/classify\",\njson={\"text\": submission, \"candidate_labels\": [\"highly relevant\", \"relevant\", \"irrelevant\"]},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nmax_score = max(label_scores.values())\nchosen_label = [k for k, v in label_scores.items() if v == max_score][0]\nprint(f\"Evidence submitted: {submission}\")\nprint(f\"Judged as: {chosen_label}\")\n# Evidence submitted: The defendant's fingerprints were found on the weapon.\n# Judged as: highly relevant\n# Evidence submitted: A witness reported seeing the defendant near the crime scene.\n# Judged as: highly relevant\n
There are 218 models under \"zero-shot-classification\" on the huggingface hub but a simple search for nli turns up 822 models so there are a lot of models that are not tagged properly. NLI is a very interesting and a core NLP task and a few good general models can be turned into a lot of fun!
"},{"location":"blog/huggingface/ocr/","title":"Host OCR Models Using Geniusrise","text":"
Optical Character Recognition (OCR) technology has revolutionized the way we process and digitize printed or handwritten documents, making it easier to edit, search, and store textual content in digital formats. Geniusrise facilitates the deployment of OCR models as APIs, enabling developers to integrate OCR capabilities into their applications seamlessly. This guide will demonstrate setting up OCR APIs using Geniusrise, covering the configuration, usage examples, and highlighting different use cases.
"},{"location":"blog/huggingface/ocr/#setup-and-configuration","title":"Setup and Configuration","text":"
This YAML file configures an OCR API utilizing EasyOCR. Like with PaddleOCR, you'll need to execute genius rise to get the API running.
"},{"location":"blog/huggingface/ocr/#general-api-interaction-examples","title":"General API Interaction Examples","text":"
Interacting with these OCR APIs can be done through HTTP requests, where you send a base64-encoded image and receive the detected text in response. Here's a generic example on how to send a request to either OCR API configured above:
"},{"location":"blog/huggingface/ocr/#example-with-curl","title":"Example with curl:","text":"
To adapt the API for various OCR tasks, such as document digitization, receipt scanning, or handwritten note conversion, you can switch the model_name in your genius.yml:
Document OCR: Use models like paddleocr for general document recognition.
Handwritten OCR: Opt for models specifically fine-tuned for handwriting, such as facebook/nougat-base.
Receipt OCR: Utilize domain-specific models designed for extracting information from receipts or invoices.
For advanced OCR needs, additional parameters can be included in your request to customize the OCR process, such as specifying the language, adjusting the resolution, or defining the output format.
"},{"location":"blog/huggingface/qa/","title":"Host Question Answering Models Using Geniusrise","text":"
Host Question Answering Models Using Geniusrise
Types of Question Answering Tasks
Generative
Extractive
Why Extractive May be Better
Installation and Configuration
Understanding genius.yml
Use Cases \\& Variations
Making API Requests
Direct Question Answering API
Hugging Face Pipeline API
Fun
Long contexts
Domain-specific
Play around
Deploying question answering (QA) models can significantly enhance the capabilities of applications, providing users with specific, concise answers to their queries. Geniusrise simplifies this process, enabling developers to rapidly set up and deploy QA APIs. This guide will walk you through the steps to create inference APIs for different QA tasks using Geniusrise, focusing on configuring the genius.yml file and providing interaction examples via curl and python-requests.
"},{"location":"blog/huggingface/qa/#types-of-question-answering-tasks","title":"Types of Question Answering Tasks","text":"
Before diving into the setup and deployment of question answering (QA) models using Geniusrise, it's essential to understand the two main types of QA tasks: generative and extractive. This distinction is crucial for selecting the right model for your application and configuring your genius.yml file accordingly.
Generative QA models are designed to produce answers by generating text based on the context and the question asked. These models do not restrict their responses to the text's snippets but rather \"generate\" a new text passage that answers the question. Generative models are powerful for open-ended questions where the answer may not be directly present in the context or requires synthesis of information from multiple parts of the context.
Extractive QA models, on the other hand, identify and extract a specific snippet from the provided text that answers the question. This approach is particularly effective for factual questions where the answer is explicitly stated in the text. Extractive QA is advantageous because it limits the model's responses to the actual content of the input text, reducing the chances of hallucination (producing incorrect or unfounded information) that can occur with generative models.
"},{"location":"blog/huggingface/qa/#why-extractive-may-be-better","title":"Why Extractive May be Better","text":"
Accuracy: Extractive QA models provide answers directly sourced from the input text, ensuring that the information is accurate and grounded in the provided context.
Reliability: By constraining the answers to the text snippets, extractive QA minimizes the risk of hallucinations, making it a reliable choice for applications where factual correctness is paramount.
Efficiency for RAG: Extractive QA tasks can be particularly efficient for Retrieval-Augmented Generation (RAG) because they allow for precise information retrieval without the need for generating new text, which can be computationally more demanding.
The models discussed in this guide focus on extractive QA tasks, which are particularly well-suited for direct, fact-based question answering from provided texts.
Extractive QA models are ideal for applications requiring high precision and direct answers from given texts.
"},{"location":"blog/huggingface/qa/#installation-and-configuration","title":"Installation and Configuration","text":"
Requirements
python 3.10, PPA, AUR, brew, Windows.
You need to have a GPU. Most of the system works with NVIDIA GPUs.
To adapt the API for various QA tasks, simply change the model_name in your genius.yml. For example, to switch to a model specializing in medical QA, you might use bert-large-uncased-whole-word-masking-finetuned-squad for broader coverage of medical inquiries.
"},{"location":"blog/huggingface/qa/#making-api-requests","title":"Making API Requests","text":"
Geniusrise enables two primary ways to interact with your Question Answering API: through direct question-answering and utilizing the Hugging Face pipeline. Below, we provide examples on how to use both endpoints using curl and python-requests.
This API endpoint directly answers questions based on the provided context.
Using curl:
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"question\": \"What is the common wisdom about RNNs?\"\n }' | jq\n
Using python-requests:
import requests\ndata = {\n\"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n\"question\": \"What is the common wisdom about RNNs?\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/answer\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
"},{"location":"blog/huggingface/qa/#hugging-face-pipeline-api","title":"Hugging Face Pipeline API","text":"
This API endpoint leverages the Hugging Face pipeline for answering questions, offering a streamlined way to use pre-trained models for question answering.
Using curl:
curl -X POST http://localhost:3000/api/v1/answer_pipeline \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"question\": \"Who created Geniusrise?\", \"data\": \"Geniusrise was created by a team of dedicated developers.\"}'\n
Using python-requests:
import requests\ndata = {\n\"question\": \"Who created Geniusrise?\",\n\"data\": \"Geniusrise was created by a team of dedicated developers.\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/answer_pipeline\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
An usual problem that faces QA models is small context sizes. This limits the model's capabilities for processing large documents or large amounts of text in their inputs. Though language models keep getting bigger contexts, QA models on the other hand tend to be much smaller and support smaller contexts.
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me. This post is about sharing some of that magic with you. By the way, together with this post I am also releasing code on Github that allows you to train character-level language models based on multi-layer LSTMs. You give it a large chunk of text and it will learn to generate text like it one character at a time. You can also use it to reproduce my experiments below. But we\u2019re getting ahead of ourselves; What are RNNs anyway? Recurrent Neural Networks Sequences. Depending on your background you might be wondering: What makes Recurrent Networks so special? A glaring limitation of Vanilla Neural Networks (and also Convolutional Networks) is that their API is too constrained: they accept a fixed-sized vector as input (e.g. an image) and produce a fixed-sized vector as output (e.g. probabilities of different classes). Not only that: These models perform this mapping using a fixed amount of computational steps (e.g. the number of layers in the model). The core reason that recurrent nets are more exciting is that they allow us to operate over sequences of vectors: Sequences in the input, the output, or in the most general case both. A few examples may make this more concrete: Each rectangle is a vector and arrows represent functions (e.g. matrix multiply). Input vectors are in red, output vectors are in blue and green vectors hold the RNNs state (more on this soon). From left to right: (1) Vanilla mode of processing without RNN, from fixed-sized input to fixed-sized output (e.g. image classification). (2) Sequence output (e.g. image captioning takes an image and outputs a sentence of words). (3) Sequence input (e.g. sentiment analysis where a given sentence is classified as expressing positive or negative sentiment). (4) Sequence input and sequence output (e.g. Machine Translation: an RNN reads a sentence in English and then outputs a sentence in French). (5) Synced sequence input and output (e.g. video classification where we wish to label each frame of the video). Notice that in every case are no pre-specified constraints on the lengths sequences because the recurrent transformation (green) is fixed and can be applied as many times as we like. As you might expect, the sequence regime of operation is much more powerful compared to fixed networks that are doomed from the get-go by a fixed number of computational steps, and hence also much more appealing for those of us who aspire to build more intelligent systems. Moreover, as we\u2019ll see in a bit, RNNs combine the input vector with their state vector with a fixed (but learned) function to produce a new state vector. This can in programming terms be interpreted as running a fixed program with certain inputs and some internal variables. Viewed this way, RNNs essentially describe programs. In fact, it is known that RNNs are Turing-Complete in the sense that they can to simulate arbitrary programs (with proper weights). But similar to universal approximation theorems for neural nets you shouldn\u2019t read too much into this. In fact, forget I said anything.\",\n \"question\": \"What do the models essentially do?\"\n }' | jq\n\n# {\n# \"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me. This post is about sharing some of that magic with you. By the way, together with this post I am also releasing code on Github that allows you to train character-level language models based on multi-layer LSTMs. You give it a large chunk of text and it will learn to generate text like it one character at a time. You can also use it to reproduce my experiments below. But we\u2019re getting ahead of ourselves; What are RNNs anyway? Recurrent Neural Networks Sequences. Depending on your background you might be wondering: What makes Recurrent Networks so special? A glaring limitation of Vanilla Neural Networks (and also Convolutional Networks) is that their API is too constrained: they accept a fixed-sized vector as input (e.g. an image) and produce a fixed-sized vector as output (e.g. probabilities of different classes). Not only that: These models perform this mapping using a fixed amount of computational steps (e.g. the number of layers in the model). The core reason that recurrent nets are more exciting is that they allow us to operate over sequences of vectors: Sequences in the input, the output, or in the most general case both. A few examples may make this more concrete: Each rectangle is a vector and arrows represent functions (e.g. matrix multiply). Input vectors are in red, output vectors are in blue and green vectors hold the RNNs state (more on this soon). From left to right: (1) Vanilla mode of processing without RNN, from fixed-sized input to fixed-sized output (e.g. image classification). (2) Sequence output (e.g. image captioning takes an image and outputs a sentence of words). (3) Sequence input (e.g. sentiment analysis where a given sentence is classified as expressing positive or negative sentiment). (4) Sequence input and sequence output (e.g. Machine Translation: an RNN reads a sentence in English and then outputs a sentence in French). (5) Synced sequence input and output (e.g. video classification where we wish to label each frame of the video). Notice that in every case are no pre-specified constraints on the lengths sequences because the recurrent transformation (green) is fixed and can be applied as many times as we like. As you might expect, the sequence regime of operation is much more powerful compared to fixed networks that are doomed from the get-go by a fixed number of computational steps, and hence also much more appealing for those of us who aspire to build more intelligent systems. Moreover, as we\u2019ll see in a bit, RNNs combine the input vector with their state vector with a fixed (but learned) function to produce a new state vector. This can in programming terms be interpreted as running a fixed program with certain inputs and some internal variables. Viewed this way, RNNs essentially describe programs. In fact, it is known that RNNs are Turing-Complete in the sense that they can to simulate arbitrary programs (with proper weights). But similar to universal approximation theorems for neural nets you shouldn\u2019t read too much into this. In fact, forget I said anything.\",\n# \"question\": \"What do the models essentially do?\",\n# \"answer\": {\n# \"answers\": [\n# \"they allow us to operate over sequences of vectors\" <---\n# ],\n# \"aggregation\": \"NONE\"\n# }\n# }\n
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"data\": \"The choice of medication or combination of medications depends on various factors, including your personal risk factors, your age, your health and possible drug side effects. Common choices include: Statins. Statins block a substance your liver needs to make cholesterol. This causes your liver to remove cholesterol from your blood. Choices include atorvastatin, fluvastatin, lovastatin, pitavastatin, rosuvastatin and simvastatin. Cholesterol absorption inhibitors. The drug ezetimibe helps reduce blood cholesterol by limiting the absorption of dietary cholesterol. Ezetimibe can be used with a statin drug. Bempedoic acid. This newer drug works in much the same way as statins but is less likely to cause muscle pain. Adding bempedoic acid to a maximum statin dosage can help lower LDL significantly. A combination pill containing both bempedoic acid and ezetimibe also is available. Bile-acid-binding resins. Your liver uses cholesterol to make bile acids, a substance needed for digestion. The medications cholestyramine, colesevelam and colestipol lower cholesterol indirectly by binding to bile acids. This prompts your liver to use excess cholesterol to make more bile acids, which reduces the level of cholesterol in your blood. PCSK9 inhibitors. These drugs can help the liver absorb more LDL cholesterol, which lowers the amount of cholesterol circulating in your blood. Alirocumab and evolocumab might be used for people who have a genetic condition that causes very high levels of LDL or in people with a history of coronary disease who have intolerance to statins or other cholesterol medications. They are injected under the skin every few weeks and are expensive. Medications for high triglycerides If you also have high triglycerides, your doctor might prescribe: Fibrates. The medications fenofibrate and gemfibrozil reduce your liver s production of very-low-density lipoprotein cholesterol and speed the removal of triglycerides from your blood. VLDL cholesterol contains mostly triglycerides. Using fibrates with a statin can increase the risk of statin side effects. Omega-3 fatty acid supplements. Omega-3 fatty acid supplements can help lower your triglycerides. They are available by prescription or over-the-counter.\",\n \"question\": \"What do i take if i have high VLDL?\"\n }' | jq\n\n# {\n# \"data\": \"The choice of medication or combination of medications depends on various factors, including your personal risk factors, your age, your health and possible drug side effects. Common choices include: Statins. Statins block a substance your liver needs to make cholesterol. This causes your liver to remove cholesterol from your blood. Choices include atorvastatin, fluvastatin, lovastatin, pitavastatin, rosuvastatin and simvastatin. Cholesterol absorption inhibitors. The drug ezetimibe helps reduce blood cholesterol by limiting the absorption of dietary cholesterol. Ezetimibe can be used with a statin drug. Bempedoic acid. This newer drug works in much the same way as statins but is less likely to cause muscle pain. Adding bempedoic acid to a maximum statin dosage can help lower LDL significantly. A combination pill containing both bempedoic acid and ezetimibe also is available. Bile-acid-binding resins. Your liver uses cholesterol to make bile acids, a substance needed for digestion. The medications cholestyramine, colesevelam and colestipol lower cholesterol indirectly by binding to bile acids. This prompts your liver to use excess cholesterol to make more bile acids, which reduces the level of cholesterol in your blood. PCSK9 inhibitors. These drugs can help the liver absorb more LDL cholesterol, which lowers the amount of cholesterol circulating in your blood. Alirocumab and evolocumab might be used for people who have a genetic condition that causes very high levels of LDL or in people with a history of coronary disease who have intolerance to statins or other cholesterol medications. They are injected under the skin every few weeks and are expensive. Medications for high triglycerides If you also have high triglycerides, your doctor might prescribe: Fibrates. The medications fenofibrate and gemfibrozil reduce your liver s production of very-low-density lipoprotein cholesterol and speed the removal of triglycerides from your blood. VLDL cholesterol contains mostly triglycerides. Using fibrates with a statin can increase the risk of statin side effects. Omega-3 fatty acid supplements. Omega-3 fatty acid supplements can help lower your triglycerides. They are available by prescription or over-the-counter.\",\n# \"question\": \"What do i take if i have high VLDL?\",\n# \"answer\": {\n# \"answers\": [\n# \"fibrates\" <-------\n# ],\n# \"aggregation\": \"NONE\"\n# }\n# }\n
Now there are also models like the sloshed lawyer but they are not recommended in production \ud83d\ude06
There are 9,593 QA models huggingface, go exlpore!
"},{"location":"blog/huggingface/segment/","title":"Host Segmentation Models Using Geniusrise","text":"
Segmentation models are pivotal in computer vision, allowing developers to delineate and understand the context within images by classifying each pixel into a set category. This capability is crucial for tasks ranging from autonomous driving to medical imaging. Geniusrise enables easy deployment of segmentation models as APIs, facilitating the integration of advanced vision capabilities into applications. This guide will demonstrate how to set up APIs for various segmentation tasks using Geniusrise, including semantic segmentation, panoptic segmentation, and instance segmentation.
"},{"location":"blog/huggingface/segment/#setup-and-configuration","title":"Setup and Configuration","text":"
Installation:
To begin, ensure that Geniusrise and its text extension are installed:
model_name: The pre-trained model identifier, adaptable based on the segmentation task (semantic, panoptic, instance).
model_class & processor_class: Specify the model and processor classes, essential for interpreting and processing images.
device_map & use_cuda: Configure GPU acceleration for enhanced processing speed.
endpoint, port, username, & password: Network settings and authentication for API access.
"},{"location":"blog/huggingface/segment/#interacting-with-the-segmentation-api","title":"Interacting with the Segmentation API","text":"
The interaction involves sending a base64-encoded image to the API and receiving segmented output. Here's how to execute this using curl and python-requests:
"},{"location":"blog/huggingface/segment/#example-with-curl","title":"Example with curl:","text":"
By modifying the subtask parameter, you can tailor the API for various segmentation models:
Semantic Segmentation: Classifies each pixel into a predefined category. Useful in urban scene understanding and medical image analysis.
Panoptic Segmentation: Combines semantic and instance segmentation, identifying and delineating each object instance. Ideal for detailed scene analysis.
Instance Segmentation: Identifies each instance of each object category. Used in scenarios requiring precise object boundaries.
For advanced segmentation needs, additional parameters can be included in your request to customize the processing, such as specifying the output resolution or the segmentation task (semantic, panoptic, instance).
"},{"location":"blog/huggingface/speak/","title":"Host Text to Speech Models Using Geniusrise","text":"
Text to Speech (TTS) technology has transformed how we interact with digital devices, making information more accessible and enhancing user experiences. Geniusrise simplifies the deployment of TTS models as APIs, allowing developers to incorporate high-quality voice synthesis into their applications. This guide focuses on setting up TTS APIs with Geniusrise, showcasing various use cases and providing examples to help you get started.
Some models support different voice presets. Use the voice_preset parameter to select various voices, adjusting tone and style to fit your application's context.
For applications requiring high-fidelity audio, select models optimized for quality, such as facebook/seamless-m4t-v2-large. These models often have larger sizes but produce more natural and clear voice outputs.
For real-time TTS needs, focus on models with lower latency. Configuration options like use_cuda for GPU acceleration and precision adjustments can help reduce response times.
Model Selection: Experiment with various models to find the best fit for your application's language, quality, and performance requirements.
Security: Use the username and password fields to secure your API endpoint.
Resource Management: Adjust precision, quantization, and device_map settings based on your server's capabilities and your application's needs.
"},{"location":"blog/huggingface/speech/","title":"Host Speech to Text Models Using Geniusrise","text":"
Speech to Text (STT) technology has become a cornerstone in creating accessible and efficient user interfaces. Geniusrise offers a streamlined approach to deploying STT models as APIs, enabling developers to integrate speech recognition capabilities into their applications with ease. This post will guide you through setting up STT APIs using Geniusrise, highlighting various use cases and providing practical examples.
Handling long audio files efficiently requires chunking the audio into manageable pieces. Adjust chunk_size in your configuration to enable this feature.
For real-time applications, consider models optimized for speed and responsiveness. Adjust endpoint, port, and device_map accordingly to minimize latency.
Model Selection: Experiment with different models to find the one that best suits your needs. Geniusrise supports a wide range of STT models.
Precision and Performance: Adjust the precision and use_cuda settings to balance between transcription accuracy and resource utilization.
Security: Use username and password in your configuration to secure your API endpoint.
"},{"location":"blog/huggingface/summz/","title":"Host Summarization Models Using Geniusrise","text":"
In today's fast-paced world, the ability to condense large texts into concise summaries is invaluable. Geniusrise provides a streamlined approach to deploying summarization models as APIs, enabling developers to integrate summarization capabilities directly into their applications. This guide will walk you through setting up, configuring, and interacting with a summarization API using Geniusrise, highlighting various use cases and how to adapt the configuration for different models.
"},{"location":"blog/huggingface/summz/#setup-and-configuration","title":"Setup and Configuration","text":"
Installation:
Begin by installing Geniusrise and its text module:
endpoint & port: Network address and port for API access.
username & password: Basic authentication for API security.
"},{"location":"blog/huggingface/summz/#interacting-with-the-summarization-api","title":"Interacting with the Summarization API","text":""},{"location":"blog/huggingface/summz/#summarizing-text","title":"Summarizing Text","text":"
You can summarize text by making HTTP requests to your API.
Example with curl:
/usr/bin/curl -X POST localhost:3000/api/v1/summarize \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"decoding_strategy\": \"generate\",\n \"bos_token_id\": 0,\n \"decoder_start_token_id\": 2,\n \"early_stopping\": true,\n \"eos_token_id\": 2,\n \"forced_bos_token_id\": 0,\n \"forced_eos_token_id\": 2,\n \"length_penalty\": 2.0,\n \"max_length\": 142,\n \"min_length\": 56,\n \"no_repeat_ngram_size\": 3,\n \"num_beams\": 4,\n \"pad_token_id\": 1,\n \"do_sample\": false\n }' | jq\n
Example with python-requests:
import requests\ndata = {\n\"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n\"decoding_strategy\": \"generate\",\n\"bos_token_id\": 0,\n\"decoder_start_token_id\": 2,\n\"early_stopping\": true,\n\"eos_token_id\": 2,\n\"forced_bos_token_id\": 0,\n\"forced_eos_token_id\": 2,\n\"length_penalty\": 2.0,\n\"max_length\": 142,\n\"min_length\": 56,\n\"no_repeat_ngram_size\": 3,\n\"num_beams\": 4,\n\"pad_token_id\": 1,\n\"do_sample\": false\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/summarize\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
For use cases requiring specific summarization strategies or adjustments (e.g., length penalty, no repeat ngram size), additional parameters can be included in your request to customize the summarization output.
To cater to various summarization needs, such as domain-specific texts or languages, simply adjust the model_name in your genius.yml. For example, for summarizing scientific papers, you might choose a model like allenai/longformer-base-4096.
Adjust summarization parameters such as max_length, min_length, and num_beams to fine-tune the output based on the specific requirements of your application.
"},{"location":"blog/huggingface/table_qa/","title":"Host Table Question Answering Models Using Geniusrise","text":"
Host Table Question Answering Models Using Geniusrise
Setup and Configuration
Understanding genius.yml Parameters
Use Cases \\& Variations
Changing the Model for Different Table QA Tasks
Example genius.yml for tabular fact-checking:
Interacting with Your API
Table QA
Utilizing the Hugging Face Pipeline
Fun
Executing SQL on data
Query generators
Play around
Deploying table question answering (QA) models is a sophisticated task that Geniusrise simplifies for developers. This guide aims to demonstrate how you can use Geniusrise to set up and run APIs for table QA, a crucial functionality for extracting structured information from tabular data. We'll cover the setup process, explain the parameters in the genius.yml file with examples, and provide code snippets for interacting with your API using curl and python-requests.
"},{"location":"blog/huggingface/table_qa/#setup-and-configuration","title":"Setup and Configuration","text":"
Requirements
python 3.10, PPA, AUR, brew, Windows.
You need to have a GPU. Most of the system works with NVIDIA GPUs.
model_name: The identifier for the model from Hugging Face, designed for table QA tasks.
model_class & tokenizer_class: Specifies the classes used for the model and tokenizer, respectively, suitable for table QA.
use_cuda: Utilize GPU acceleration to speed up inference times.
precision: Determines the floating-point precision for calculations (e.g., float for single precision).
device_map: Designates model parts to specific GPUs, optimizing performance.
endpoint & port: The network address and port where the API will be accessible.
username & password: Basic authentication credentials to secure access to your API.
"},{"location":"blog/huggingface/table_qa/#use-cases-variations","title":"Use Cases & Variations","text":""},{"location":"blog/huggingface/table_qa/#changing-the-model-for-different-table-qa-tasks","title":"Changing the Model for Different Table QA Tasks","text":"
To tailor your API for different table QA tasks, such as financial data analysis or sports statistics, you can modify the model_name in your genius.yml. For example, to switch to a model optimized for financial tables, you might use google/tapas-large-finetuned-finance.
"},{"location":"blog/huggingface/table_qa/#example-geniusyml-for-tabular-fact-checking","title":"Example genius.yml for tabular fact-checking:","text":"
"},{"location":"blog/huggingface/table_qa/#interacting-with-your-api","title":"Interacting with Your API","text":""},{"location":"blog/huggingface/table_qa/#table-qa","title":"Table QA","text":"
Using curl:
curl -X POST http://localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"question\": \"Who had the highest batting average?\", \"data\": [{\"player\": \"John Doe\", \"average\": \".312\"}, {\"player\": \"Jane Roe\", \"average\": \".328\"}]}'\n
"},{"location":"blog/huggingface/table_qa/#utilizing-the-hugging-face-pipeline","title":"Utilizing the Hugging Face Pipeline","text":"
Although primarily for text-based QA, you might experiment with the pipeline for preprocessing or extracting text from tables before querying.
Using curl:
curl -X POST http://localhost:3000/api/v1/answer_pipeline \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"question\": \"What is the total revenue?\", \"data\": \"The total revenue in Q1 was $10M, and in Q2 was $15M.\"}'\n
Using python-requests:
import requests\ndata = {\n\"question\": \"What is the total revenue?\",\n\"data\": \"\nThe total revenue in Q1 was $10M, and in Q2 was $15M.\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/answer_pipeline\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
Given some data and a natural language query, these models generate a query that can be used to compute the result. These models are what power spreadsheet automations.
This kind of models are few with 82 models on the huggingface hub.
"},{"location":"blog/huggingface/trans/","title":"Host Translation Models Using Geniusrise","text":"
This guide will walk you through deploying translation models using Geniusrise, covering the setup, configuration, and interaction with the translation API for various use cases.
"},{"location":"blog/huggingface/trans/#setup-and-configuration","title":"Setup and Configuration","text":"
Requirements
python 3.10, PPA, AUR, brew, Windows.
You need to have a GPU. Most of the system works with NVIDIA GPUs.
model_name: Specifies the model to use, such as facebook/mbart-large-50-many-to-many-mmt for multilingual translation.
model_class & tokenizer_class: Defines the classes for the model and tokenizer, crucial for the translation process.
use_cuda: Indicates whether to use GPU acceleration for faster processing.
precision: The computational precision (e.g., float) affects performance and resource usage.
endpoint & port: The network address where the API is accessible.
username & password: Security credentials for accessing the API.
"},{"location":"blog/huggingface/trans/#interacting-with-the-translation-api","title":"Interacting with the Translation API","text":""},{"location":"blog/huggingface/trans/#translating-text","title":"Translating Text","text":"
Translate text from one language to another using a simple HTTP request.
For use cases requiring specific translation strategies or parameters (e.g., beam search, number of beams), you can pass additional parameters in your request to customize the translation process.
"},{"location":"blog/huggingface/trans/#use-cases-variations","title":"Use Cases & Variations","text":""},{"location":"blog/huggingface/trans/#different-language-pairs","title":"Different Language Pairs","text":"
Adjust the source_lang and target_lang parameters to cater to various language pairs, enabling translation between numerous languages supported by the chosen model.
There are two families of models from facebook that can perform any to any language translation among a large number of languages.
facebook/mbart-large-50-many-to-many-mmt: 50 languages
facebook/nllb-200-distilled-600M: 200 languages
Both the MBART and the NLLB families have several members, with facebook/nllb-moe-54b 54billion parameter mixture of experts being the largest and most capable one.
See here for the language codes for the FLORES-200 dataset.
Now how do we even verify whether this is correct? Lets reverse translate followed by sentence similarity from NLI. We need to launch 2 containers - one for translation and another for NLI:
import requests\n# First we translate this hindi sentence to tatar\ndata = {\n\"text\": \"\u0938\u0902\u092f\u0941\u0915\u094d\u0924 \u0930\u093e\u0937\u094d\u091f\u094d\u0930 \u0915\u0947 \u092a\u094d\u0930\u092e\u0941\u0916 \u0915\u093e \u0915\u0939\u0928\u093e \u0939\u0948 \u0915\u093f \u0938\u0940\u0930\u093f\u092f\u093e \u092e\u0947\u0902 \u0915\u094b\u0908 \u0938\u0948\u0928\u094d\u092f \u0938\u092e\u093e\u0927\u093e\u0928 \u0928\u0939\u0940\u0902 \u0939\u0948\",\n\"target_lang\": \"tat_Cyrl\",\n\"decoding_strategy\": \"generate\",\n\"bos_token_id\": 0,\n\"decoder_start_token_id\": 2,\n\"eos_token_id\": 2,\n\"max_length\": 200,\n\"pad_token_id\": 1\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/translate\",\njson=data,\nauth=('user', 'password'))\ntranslated = response.json()[\"translated_text\"]\n# \u0411\u041c\u041e \u0431\u0430\u0448\u043b\u044b\u0433\u044b \u0421\u04af\u0440\u0438\u044f\u0434\u04d9 \u0445\u04d9\u0440\u0431\u0438 \u0447\u0430\u0440\u0430\u043b\u0430\u0440 \u044e\u043a \u0434\u0438\u043f \u0431\u0435\u043b\u0434\u0435\u0440\u04d9\n# Then we translate the tatar back to hindi\nrev = data.copy()\nrev[\"text\"] = translated\nrev[\"target_lang\"] = \"hin_Deva\"\nresponse = requests.post(\"http://localhost:3000/api/v1/translate\",\njson=rev,\nauth=('user', 'password'))\nrev_translated = response.json()[\"translated_text\"]\n# Finally we look at similarity of the source and reverse-translated hindi sentences\ndata = {\n\"text1\": data[\"text\"],\n\"text2\": rev_translated\n}\nresponse = requests.post(\"http://localhost:3001/api/v1/textual_similarity\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n# {\n# 'text1': '\u0938\u0902\u092f\u0941\u0915\u094d\u0924 \u0930\u093e\u0937\u094d\u091f\u094d\u0930 \u0915\u0947 \u092a\u094d\u0930\u092e\u0941\u0916 \u0915\u093e \u0915\u0939\u0928\u093e \u0939\u0948 \u0915\u093f \u0938\u0940\u0930\u093f\u092f\u093e \u092e\u0947\u0902 \u0915\u094b\u0908 \u0938\u0948\u0928\u094d\u092f \u0938\u092e\u093e\u0927\u093e\u0928 \u0928\u0939\u0940\u0902 \u0939\u0948',\n# 'text2': '\u092c\u0940\u090f\u092e\u0913 \u092a\u094d\u0930\u092e\u0941\u0916 \u0928\u0947 \u0915\u0939\u093e \u0915\u093f \u0938\u0940\u0930\u093f\u092f\u093e \u092e\u0947\u0902 \u0915\u094b\u0908 \u0938\u0948\u0928\u094d\u092f \u0909\u092a\u093e\u092f \u0928\u0939\u0940\u0902 \u0939\u0948\u0902',\n# 'similarity_score': 0.9829527983379287\n# }\n
0.9829527983379287 looks like a great similarity score, so the translation really works! (or the mistakes are isomorphic) \ud83e\udd73\ud83d\udc4d"},{"location":"blog/huggingface/trans/#play-around","title":"Play around","text":"
There is not much to really do in translation except mess around with different languagues \ud83e\udd37\u200d\u2642\ufe0f Not many models either, facebook is the undisputed leader in translation models.
"},{"location":"blog/huggingface/txtclass/","title":"Host Text Classification Models Using Geniusrise","text":"
Host Text Classification Models Using Geniusrise
Quick Setup
Configuration Breakdown
Use Cases \\& Variations
Sentiment Analysis
Content Moderation
Language Detection
Making API Requests
Classify Text
Classification Pipeline
Fun
Political bias detection
Intent classification
Hallucination Evaluation
Irony Detection
Play around
This post will guide you through creating inference APIs for different text classification tasks using geniusrise, explaining the genius.yml configuration and providing examples of how to interact with your API using curl and python-requests.
For detecting the language of the input text, a model like xlm-roberta-base is suitable.
args:\n model_name: \"xlm-roberta-base\"\n
Try out various models from huggingface.
"},{"location":"blog/huggingface/txtclass/#making-api-requests","title":"Making API Requests","text":""},{"location":"blog/huggingface/txtclass/#classify-text","title":"Classify Text","text":"
cURL:
curl -X POST http://localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"text\": \"Your text here.\"}'\n
Python-Requests:
import requests\nresponse = requests.post(\"http://localhost:3000/api/v1/classify\",\njson={\"text\": \"Your text here.\"},\nauth=('user', 'password'))\nprint(response.json())\n
/usr/bin/curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"i think i agree with bjp that hindus need to be respected\"\n }' | jq\n\n# {\n# \"input\": \"i think i agree with bjp that hindus need to be respected\",\n# \"label_scores\": {\n# \"LEFT\": 0.28080788254737854,\n# \"CENTER\": 0.18140915036201477,\n# \"RIGHT\": 0.5377829670906067 # <--\n# }\n# }\n
/usr/bin/curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"these ghettos are sprawling these days and the people who live there stink\"\n }' | jq\n\n# {\n# \"input\": \"these ghettos are sprawling these days and the people who live there stink\",\n# \"label_scores\": {\n# \"LEFT\": 0.38681042194366455, # <-- NIMBY?\n# \"CENTER\": 0.20437702536582947,\n# \"RIGHT\": 0.408812552690506 # <--\n# }\n# }\n
Works fairly well empirically for medium-sized sentences and in an american context.
Text classification can be used to figure out the intent of the user in a chat conversation scenario. For e.g. to determine whether the user has an intent to explore or to buy.
/usr/bin/curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"A man walks into a bar and buys a drink [SEP] A bloke swigs alcohol at a pub\"\n }' | jq\n\n# {\n# \"input\": \"A man walks into a bar and buys a drink [SEP] A bloke swigs alcohol at a pub\",\n# \"label_scores\": [\n# 0.6105160713195801\n# ]\n# }\n
/usr/bin/curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"What a wonderful day to have a flat tire!\"\n }' | jq\n\n# {\n# \"input\": \"What a wonderful day to have a flat tire!\",\n# \"label_scores\": {\n# \"non_irony\": 0.023495545610785484,\n# \"irony\": 0.9765045046806335 <---\n# }\n# }\n
There are 49,863 text classification models as of this article on huggingface. Play around with them, tweak various parameters, learn about various usecases and cool shit that can be built with \"mere\" text classification!
"},{"location":"blog/huggingface/vqa/","title":"Host Visual QA Models Using Geniusrise","text":"
Visual Question Answering (VQA) combines the power of visual understanding with natural language processing to answer questions about images. Geniusrise offers a streamlined process to deploy VQA models as APIs, making it accessible to developers to integrate advanced AI capabilities into their applications. This blog post demonstrates how to set up VQA APIs using Geniusrise and provides examples for various use cases.
Create a genius.yml configuration file tailored to your API requirements, specifying the model, tokenizer, and additional parameters necessary for inference.
This configuration sets up a VQA API using the Pix2Struct model, ready to process images and answer questions about them.
"},{"location":"blog/huggingface/vqa/#interacting-with-your-api","title":"Interacting with Your API","text":"
To interact with your VQA API, encode your images in base64 format and construct a JSON payload with the image and the question. Here are examples using curl:
# Convert the image to base64 and prepare the payload\nbase64 -w 0 image.jpg | awk '{print \"{\\\"image_base64\\\": \\\"\"$0\"\\\", \\\"question\\\": \\\"What is in this image?\\\"}\"}' > payload.json\n\n# Send the request to your API\ncurl -X POST http://localhost:3000/api/v1/answer_question \\\n-H \"Content-Type: application/json\" \\\n-u user:password \\\n-d @payload.json | jq\n
For specialized domains, such as medical imaging or technical diagrams, tailor your genius.yml to use domain-specific models. This requires replacing the model_name, model_class, and processor_class with those suitable for your specific application.
Experiment with different models, precision levels, and CUDA settings to optimize performance and accuracy for your use case. Geniusrise allows for detailed configuration, including quantization and torchscript options, to fine-tune the deployment according to your requirements.
"},{"location":"bolts/openai/base/","title":"Base Fine Tuner","text":"
Bases: Bolt
An abstract base class for writing bolts for fine-tuning OpenAI models.
This base class is intended to be subclassed for fine-tuning OpenAI models. The chief objective of its subclasses is to load and preprocess the dataset, though of course, other methods, including fine-tuning, can be overridden for customization.
This bolt uses the OpenAI API to fine-tune a pre-trained model.
Each subclass can be invoked using the genius cli or yaml.
Name Type Description DatasetUnion[Dataset, DatasetDict, Optional[Dataset]]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/classification/#geniusrise_openai.classification.OpenAIClassificationFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/classification/#geniusrise_openai.classification.OpenAIClassificationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"label\": \"The label\"}\n
Load a commonsense reasoning dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required **kwargsAny
Additional keyword arguments.
{}
Returns:
Name Type Description DatasetUnion[Dataset, DatasetDict, Optional[Dataset]]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/commonsense_reasoning/#geniusrise_openai.commonsense_reasoning.OpenAICommonsenseReasoningFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/commonsense_reasoning/#geniusrise_openai.commonsense_reasoning.OpenAICommonsenseReasoningFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Load an instruction following dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required **kwargsAny
Additional keyword arguments.
{}
Returns:
Name Type Description DatasetUnion[Dataset, DatasetDict, Optional[Dataset]]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/instruction_tuning/#geniusrise_openai.instruction_tuning.OpenAIInstructionFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/instruction_tuning/#geniusrise_openai.instruction_tuning.OpenAIInstructionFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Load a language modeling dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required
Returns:
Name Type Description DatasetUnion[Dataset, DatasetDict, Optional[Dataset]]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/language_model/#geniusrise_openai.language_model.OpenAILanguageModelFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/language_model/#geniusrise_openai.language_model.OpenAILanguageModelFineTuner.load_dataset--dataset-files-saved-by-hugging-face-datasets-library","title":"Dataset files saved by Hugging Face datasets library","text":"
The directory should contain 'dataset_info.json' and other related files.
Load a language modeling dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required maskedbool
Whether to use masked language modeling. Defaults to True.
required max_lengthint
The maximum length for tokenization. Defaults to 512.
required
Returns:
Name Type Description DatasetNone
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/language_model/#geniusrise_openai.language_model.OpenAILanguageModelFineTuner.prepare_fine_tuning_data--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/language_model/#geniusrise_openai.language_model.OpenAILanguageModelFineTuner.prepare_fine_tuning_data--dataset-files-saved-by-hugging-face-datasets-library","title":"Dataset files saved by Hugging Face datasets library","text":"
The directory should contain 'dataset_info.json' and other related files.
Load a named entity recognition dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required
Returns:
Name Type Description DatasetDictUnion[Dataset, DatasetDict, None]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/ner/#geniusrise_openai.ner.NamedEntityRecognitionFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/ner/#geniusrise_openai.ner.NamedEntityRecognitionFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
"},{"location":"bolts/openai/question_answering/#geniusrise_openai.question_answering.OpenAIQuestionAnsweringFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/question_answering/#geniusrise_openai.question_answering.OpenAIQuestionAnsweringFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
Type Description Union[Dataset, DatasetDict, Optional[Dataset]]
Dataset | DatasetDict: The loaded dataset.
"},{"location":"bolts/openai/sentiment_analysis/#geniusrise_openai.sentiment_analysis.OpenAISentimentAnalysisFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/sentiment_analysis/#geniusrise_openai.sentiment_analysis.OpenAISentimentAnalysisFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"label\": \"The label\"}\n
"},{"location":"bolts/openai/summarization/#geniusrise_openai.summarization.OpenAISummarizationFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/summarization/#geniusrise_openai.summarization.OpenAISummarizationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"summary\": \"The summary\"}\n
"},{"location":"bolts/openai/translation/#geniusrise_openai.translation.OpenAITranslationFineTuner.load_dataset--supported-data-formats-and-structures-for-translation-tasks","title":"Supported Data Formats and Structures for Translation Tasks:","text":""},{"location":"bolts/openai/translation/#geniusrise_openai.translation.OpenAITranslationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
AirflowRunner is a utility for managing and orchestrating Airflow DAGs. It is designed to provide a command-line interface (CLI) for creating, describing, showing, deleting, and getting the status of Airflow DAGs.
This class uses the Airflow models to interact with DAGs and DockerOperator to run tasks in Docker containers. It is aimed to simplify the deployment and management of Airflow tasks, providing a straightforward way to deploy DAGs with Docker tasks from the command line.
CLI Usage
genius airflow sub-command
Sub-commands
create: Create a new DAG with the given parameters and Docker task. genius airflow create [options]
describe: Describe a specific DAG by its ID. genius airflow describe --dag_id example_dag
show: Show all available DAGs in the Airflow environment. genius airflow show
delete: Delete a specific DAG by its ID. genius airflow delete --dag_id example_dag
status: Get the status of a specific DAG by its ID. genius airflow status --dag_id example_dag --airflow_api_base_url http://localhost:8080/api/v1
Each sub-command supports various options to specify the details of the DAG or the Docker task, such as the schedule interval, start date, owner, image, command, and more.
Additional keyword arguments for initializing the spout.
Keyword Arguments:\n Batch input:\n - input_folder (str): The input folder argument.\n - input_s3_bucket (str): The input bucket argument.\n - input_s3_folder (str): The input S3 folder argument.\n Batch outupt:\n - output_folder (str): The output folder argument.\n - output_s3_bucket (str): The output bucket argument.\n - output_s3_folder (str): The output S3 folder argument.\n Streaming input:\n - input_kafka_cluster_connection_string (str): The input Kafka servers argument.\n - input_kafka_topic (str): The input kafka topic argument.\n - input_kafka_consumer_group_id (str): The Kafka consumer group id.\n Streaming output:\n - output_kafka_cluster_connection_string (str): The output Kafka servers argument.\n - output_kafka_topic (str): The output kafka topic argument.\n Redis state manager config:\n - redis_host (str): The host address for the Redis server.\n - redis_port (int): The port number for the Redis server.\n - redis_db (int): The Redis database to be used.\n Postgres state manager config:\n - postgres_host (str): The host address for the PostgreSQL server.\n - postgres_port (int): The port number for the PostgreSQL server.\n - postgres_user (str): The username for the PostgreSQL server.\n - postgres_password (str): The password for the PostgreSQL server.\n - postgres_database (str): The PostgreSQL database to be used.\n - postgres_table (str): The PostgreSQL table to be used.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The name of the DynamoDB table.\n - dynamodb_region_name (str): The AWS region for DynamoDB.\n Deployment\n - k8s_kind (str): Kind opf kubernetes resource to be deployed as, choices are \"deployment\", \"service\", \"job\", \"cron_job\"\n - k8s_name (str): Name of the Kubernetes resource.\n - k8s_image (str): Docker image for the Kubernetes resource.\n - k8s_replicas (int): Number of replicas.\n - k8s_env_vars (json): Environment variables as a JSON string.\n - k8s_cpu (str): CPU requirements.\n - k8s_memory (str): Memory requirements.\n - k8s_storage (str): Storage requirements.\n - k8s_gpu (str): GPU requirements.\n - k8s_kube_config_path (str): Name of the Kubernetes cluster local config.\n - k8s_api_key (str): GPU requirements.\n - k8s_api_host (str): GPU requirements.\n - k8s_verify_ssl (str): GPU requirements.\n - k8s_ssl_ca_cert (str): GPU requirements.\n - k8s_cluster_name (str): Name of the Kubernetes cluster.\n - k8s_context_name (str): Name of the kubeconfig context.\n - k8s_namespace (str): Kubernetes namespace.\", default=\"default\n - k8s_labels (json): Labels for Kubernetes resources, as a JSON string.\n - k8s_annotations (json): Annotations for Kubernetes resources, as a JSON string.\n - k8s_port (int): Port to run the spout on as a service.\n - k8s_target_port (int): Port to expose the spout on as a service.\n - k8s_schedule (str): Schedule to run the spout on as a cron job.\n
The type of state manager (\"none\", \"redis\", \"postgres\", or \"dynamodb\").
required **kwargs
Additional keyword arguments for initializing the spout.
Keyword Arguments:\n Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n Streaming output:\n - output_kafka_topic (str): Kafka output topic for streaming spouts.\n - output_kafka_cluster_connection_string (str): Kafka connection string for streaming spouts.\n Stream to Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n - buffer_size (int): Number of messages to buffer.\n Redis state manager config:\n - redis_host (str): The host address for the Redis server.\n - redis_port (int): The port number for the Redis server.\n - redis_db (int): The Redis database to be used.\n Postgres state manager config:\n - postgres_host (str): The host address for the PostgreSQL server.\n - postgres_port (int): The port number for the PostgreSQL server.\n - postgres_user (str): The username for the PostgreSQL server.\n - postgres_password (str): The password for the PostgreSQL server.\n - postgres_database (str): The PostgreSQL database to be used.\n - postgres_table (str): The PostgreSQL table to be used.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The name of the DynamoDB table.\n - dynamodb_region_name (str): The AWS region for DynamoDB.\n
Additional keyword arguments for initializing the spout.
Keyword Arguments:\n Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n Streaming output:\n - output_kafka_topic (str): Kafka output topic for streaming spouts.\n - output_kafka_cluster_connection_string (str): Kafka connection string for streaming spouts.\n Stream to Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n - buffer_size (int): Number of messages to buffer.\n Redis state manager config:\n - redis_host (str): The host address for the Redis server.\n - redis_port (int): The port number for the Redis server.\n - redis_db (int): The Redis database to be used.\n Postgres state manager config:\n - postgres_host (str): The host address for the PostgreSQL server.\n - postgres_port (int): The port number for the PostgreSQL server.\n - postgres_user (str): The username for the PostgreSQL server.\n - postgres_password (str): The password for the PostgreSQL server.\n - postgres_database (str): The PostgreSQL database to be used.\n - postgres_table (str): The PostgreSQL table to be used.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The name of the DynamoDB table.\n - dynamodb_region_name (str): The AWS region for DynamoDB.\n Deployment\n - k8s_kind (str): Kind opf kubernetes resource to be deployed as, choices are \"deployment\", \"service\", \"job\", \"cron_job\"\n - k8s_name (str): Name of the Kubernetes resource.\n - k8s_image (str): Docker image for the Kubernetes resource.\n - k8s_replicas (int): Number of replicas.\n - k8s_env_vars (json): Environment variables as a JSON string.\n - k8s_cpu (str): CPU requirements.\n - k8s_memory (str): Memory requirements.\n - k8s_storage (str): Storage requirements.\n - k8s_gpu (str): GPU requirements.\n - k8s_kube_config_path (str): Name of the Kubernetes cluster local config.\n - k8s_api_key (str): GPU requirements.\n - k8s_api_host (str): GPU requirements.\n - k8s_verify_ssl (str): GPU requirements.\n - k8s_ssl_ca_cert (str): GPU requirements.\n - k8s_cluster_name (str): Name of the Kubernetes cluster.\n - k8s_context_name (str): Name of the kubeconfig context.\n - k8s_namespace (str): Kubernetes namespace.\", default=\"default\n - k8s_labels (json): Labels for Kubernetes resources, as a JSON string.\n - k8s_annotations (json): Annotations for Kubernetes resources, as a JSON string.\n - k8s_port (int): Port to run the spout on as a service.\n - k8s_target_port (int): Port to expose the spout on as a service.\n - k8s_schedule (str): Schedule to run the spout on as a cron job.\n
Command-line interface for managing spouts and bolts based on a YAML configuration.
The YamlCtl class provides methods to run specific or all spouts and bolts defined in a YAML file. The YAML file's structure is defined by the Geniusfile schema.
Run the command-line interface for managing spouts and bolts based on provided arguments. Please note that there is no ordering of the spouts and bolts in the YAML configuration. Each spout and bolt is an independent entity even when connected together.
Parameters:
Name Type Description Default argsargparse.Namespace
The Bolt class is a base class for all bolts in the given context. It inherits from the Task class and provides methods for executing tasks both locally and remotely, as well as managing their state, with state management options including in-memory, Redis, PostgreSQL, and DynamoDB, and input and output data for batch, streaming, stream-to-batch, and batch-to-streaming.
The Bolt class uses the Input, Output and State classes, which are abstract base classes for managing input data, output data and states, respectively. The Input and Output classes each have two subclasses: StreamingInput, BatchInput, StreamingOutput and BatchOutput, which manage streaming and batch input and output data, respectively. The State class is used to get and set state, and it has several subclasses for different types of state managers.
The Bolt class also uses the ECSManager and K8sManager classes in the execute_remote method, which are used to manage tasks on Amazon ECS and Kubernetes, respectively.
Usage
Create an instance of the Bolt class by providing an Input object, an Output object and a State object.
The Input object specifies the input data for the bolt.
The Output object specifies the output data for the bolt.
The State object handles the management of the bolt's state.
This static method is used to create a bolt of a specific type. It takes in an input type, an output type, a state type, and additional keyword arguments for initializing the bolt.
The method creates the input, output, and state manager based on the provided types, and then creates and returns a bolt using these configurations.
Parameters:
Name Type Description Default klasstype
The Bolt class to create.
required input_typestr
The type of input (\"batch\" or \"streaming\").
required output_typestr
The type of output (\"batch\" or \"streaming\").
required state_typestr
The type of state manager (\"none\", \"redis\", \"postgres\", or \"dynamodb\").
required **kwargs
Additional keyword arguments for initializing the bolt.
Keyword Arguments:\n Batch input:\n - input_folder (str): The input folder argument.\n - input_s3_bucket (str): The input bucket argument.\n - input_s3_folder (str): The input S3 folder argument.\n Batch output config:\n - output_folder (str): The output folder argument.\n - output_s3_bucket (str): The output bucket argument.\n - output_s3_folder (str): The output S3 folder argument.\n Streaming input:\n - input_kafka_cluster_connection_string (str): The input Kafka servers argument.\n - input_kafka_topic (str): The input kafka topic argument.\n - input_kafka_consumer_group_id (str): The Kafka consumer group id.\n Streaming output:\n - output_kafka_cluster_connection_string (str): The output Kafka servers argument.\n - output_kafka_topic (str): The output kafka topic argument.\n Stream-to-Batch input:\n - buffer_size (int): Number of messages to buffer.\n - input_kafka_cluster_connection_string (str): The input Kafka servers argument.\n - input_kafka_topic (str): The input kafka topic argument.\n - input_kafka_consumer_group_id (str): The Kafka consumer group id.\n Batch-to-Streaming input:\n - buffer_size (int): Number of messages to buffer.\n - input_folder (str): The input folder argument.\n - input_s3_bucket (str): The input bucket argument.\n - input_s3_folder (str): The input S3 folder argument.\n Stream-to-Batch output:\n - buffer_size (int): Number of messages to buffer.\n - output_folder (str): The output folder argument.\n - output_s3_bucket (str): The output bucket argument.\n - output_s3_folder (str): The output S3 folder argument.\n Redis state manager config:\n - redis_host (str): The Redis host argument.\n - redis_port (str): The Redis port argument.\n - redis_db (str): The Redis database argument.\n Postgres state manager config:\n - postgres_host (str): The PostgreSQL host argument.\n - postgres_port (str): The PostgreSQL port argument.\n - postgres_user (str): The PostgreSQL user argument.\n - postgres_password (str): The PostgreSQL password argument.\n - postgres_database (str): The PostgreSQL database argument.\n - postgres_table (str): The PostgreSQL table argument.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The DynamoDB table name argument.\n - dynamodb_region_name (str): The DynamoDB region name argument.\n
{}
Returns:
Name Type Description BoltBolt
The created bolt.
Raises:
Type Description ValueError
If an invalid input type, output type, or state type is provided.
"},{"location":"core/core_data_batch_input/","title":"Batch data input","text":"
"},{"location":"core/core_data_batch_input/#core.data.batch_input.BatchInput--get-the-input-folder","title":"Get the input folder","text":"
folder = input.get()\n
"},{"location":"core/core_data_batch_input/#core.data.batch_input.BatchInput--save-a-spark-dataframe-to-the-input-folder","title":"Save a Spark DataFrame to the input folder","text":"
"},{"location":"core/core_data_batch_input/#core.data.batch_input.BatchInput--copy-files-from-s3-to-the-input-folder","title":"Copy files from S3 to the input folder","text":"
Consume messages from a Kafka topic and save them as JSON files in the input folder. Stops consuming after reaching the latest message or the specified number of messages.
Parameters:
Name Type Description Default input_topicstr
Kafka topic to consume data from.
required kafka_cluster_connection_stringstr
Connection string for the Kafka cluster.
required nr_messagesint
Number of messages to consume. Defaults to 1000.
1000group_idstr
Kafka consumer group ID. Defaults to \"geniusrise\".
'geniusrise'partition_schemeOptional[str]
Optional partitioning scheme for Kafka, e.g., \"year/month/day\".
None
Returns:
Name Type Description strstr
The path to the folder where the consumed messages are saved as JSON files.
Partitioning scheme for S3, e.g., \"year/month/day\".
Raises:
Type Description FileNotExistError
If the output folder does not exist.
Parameters:
Name Type Description Default output_folderstr
Folder to save output files.
required bucketstr
S3 bucket name.
required s3_folderstr
Folder within the S3 bucket.
required partition_schemeOptional[str]
Partitioning scheme for S3, e.g., \"year/month/day\".
None Usage
# Initialize the BatchOutput instance\nconfig = BatchOutput(\"/path/to/output\", \"my_bucket\", \"s3/folder\", partition_scheme=\"%Y/%m/%d\")\n# Save data to a file\nconfig.save({\"key\": \"value\"}, \"example.json\")\n# Compose multiple BatchOutput instances\nresult = config1.compose(config2, config3)\n# Convert output to a Spark DataFrame\nspark_df = config.to_spark(spark_session)\n# Copy files to a remote S3 bucket\nconfig.to_s3()\n# Flush the output to S3\nconfig.flush()\n# Collect metrics\nmetrics = config.collect_metrics()\n
\ud83d\udce1 StreamingInput: Manages streaming input data from Kafka and other streaming sources.
Attributes:
Name Type Description input_topicstr
Kafka topic to consume data from.
kafka_cluster_connection_stringstr
Connection string for the Kafka cluster.
group_idstr
Kafka consumer group ID.
consumerKafkaConsumer
Kafka consumer instance.
Usage
input = StreamingInput(\"my_topic\", \"localhost:9094\") for message in input.get(): print(message.value)
Parameters:
Name Type Description Default input_topicstr
Kafka topic to consume data from.
required kafka_cluster_connection_stringstr
Connection string for the Kafka cluster.
required group_idstr
Kafka consumer group ID. Defaults to \"geniusrise\".
'geniusrise'**kwargs
Additional keyword arguments for KafkaConsumer.
{}
Raises:
Type Description KafkaConnectionError
If unable to connect to Kafka.
Usage"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-get-method-to-consume-from-kafka","title":"Using get method to consume from Kafka","text":"
input = StreamingInput(\"my_topic\", \"localhost:9094\")\nconsumer = input.get()\nfor message in consumer:\nprint(message.value)\n
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-from_streamz-method-to-process-streamz-dataframe","title":"Using from_streamz method to process streamz DataFrame","text":"
input = StreamingInput(\"my_topic\", \"localhost:9094\")\nstreamz_df = ... # Assume this is a streamz DataFrame\nfor row in input.from_streamz(streamz_df):\nprint(row)\n
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-from_spark-method-to-process-spark-dataframe","title":"Using from_spark method to process Spark DataFrame","text":"
input = StreamingInput(\"my_topic\", \"localhost:9094\")\nspark_df = ... # Assume this is a Spark DataFrame\nmap_func = lambda row: {\"key\": row.key, \"value\": row.value}\nquery_or_rdd = input.from_spark(spark_df, map_func)\n
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-compose-method-to-merge-multiple-streaminginput-instances","title":"Using compose method to merge multiple StreamingInput instances","text":"
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-close-method-to-close-the-kafka-consumer","title":"Using close method to close the Kafka consumer","text":"
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-seek-method-to-seek-to-a-specific-offset","title":"Using seek method to seek to a specific offset","text":"
The Spout class is a base class for all spouts in the given context. It inherits from the Task class and provides methods for executing tasks both locally and remotely, as well as managing their state, with state management options including in-memory, Redis, PostgreSQL, and DynamoDB, and output data for batch or streaming data.
The Spout class uses the Output and State classes, which are abstract base classes for managing output data and states, respectively. The Output class has two subclasses: StreamingOutput and BatchOutput, which manage streaming and batch output data, respectively. The State class is used to get and set state, and it has several subclasses for different types of state managers.
The Spout class also uses the ECSManager and K8sManager classes in the execute_remote method, which are used to manage tasks on Amazon ECS and Kubernetes, respectively.
Usage
Create an instance of the Spout class by providing an Output object and a State object.
The Output object specifies the output data for the spout.
The State object handles the management of the spout's state.
Example
output = Output(...) state = State(...) spout = Spout(output, state)
The type of state manager (\"none\", \"redis\", \"postgres\", or \"dynamodb\").
required **kwargs
Additional keyword arguments for initializing the spout.
Keyword Arguments:\n Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n Streaming output:\n - output_kafka_topic (str): Kafka output topic for streaming spouts.\n - output_kafka_cluster_connection_string (str): Kafka connection string for streaming spouts.\n Stream to Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n - buffer_size (int): Number of messages to buffer.\n Redis state manager config:\n - redis_host (str): The host address for the Redis server.\n - redis_port (int): The port number for the Redis server.\n - redis_db (int): The Redis database to be used.\n Postgres state manager config:\n - postgres_host (str): The host address for the PostgreSQL server.\n - postgres_port (int): The port number for the PostgreSQL server.\n - postgres_user (str): The username for the PostgreSQL server.\n - postgres_password (str): The password for the PostgreSQL server.\n - postgres_database (str): The PostgreSQL database to be used.\n - postgres_table (str): The PostgreSQL table to be used.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The name of the DynamoDB table.\n - dynamodb_region_name (str): The AWS region for DynamoDB\n
{}
Returns:
Name Type Description SpoutSpout
The created spout.
Raises:
Type Description ValueError
If an invalid output type or state type is provided.
\ud83d\udee0\ufe0f Task: Class for managing tasks.
This class provides a foundation for creating and managing tasks. Each task has a unique identifier and can be associated with specific input and output data.
\ud83d\udda8\ufe0f Pretty print the fetch_* methods and their parameters along with their default values and docstrings. Also prints the class's docstring and init parameters.
DockerResourceManager is a utility for managing Docker resources, including containers and images. It provides a command-line interface (CLI) for various Docker operations, such as listing, inspecting, creating, starting, and stopping containers, as well as managing images.
This class uses the Docker SDK for Python to interact with the Docker daemon, offering a convenient way to manage Docker containers and images from the command line.
CLI Usage
genius docker sub-command
Sub-commands
list_containers: List all containers, with an option to include stopped containers. genius docker list_containers [--all]
inspect_container: Inspect a specific container by its ID. genius docker inspect_container <container_id>
create_container: Create a new container with specified image, command, and other parameters. genius docker create_container <image> [options]
start_container: Start a container by its ID. genius docker start_container <container_id>
stop_container: Stop a container by its ID. genius docker stop_container <container_id>
list_images: List all Docker images available on the local system. genius docker list_images
inspect_image: Inspect a specific image by its ID. genius docker inspect_image <image_id>
pull_image: Pull an image from a Docker registry. genius docker pull_image <image>
push_image: Push an image to a Docker registry. genius docker push_image <image>
Each sub-command supports various options to specify the details of the container or image operation, such as environment variables, port mappings, volume mappings, and more.
Attributes:
Name Type Description client
The Docker client connection to interact with the Docker daemon.
log
Logger for the class to log information, warnings, and errors.
console
Rich console object to print formatted and styled outputs.
Methods
connect: Method to establish a connection to the Docker daemon.
list_containers: Method to list all containers, with an option to include stopped ones.
inspect_container: Method to inspect details of a specific container.
create_container: Method to create a new container with given parameters.
start_container: Method to start a specific container.
stop_container: Method to stop a specific container.
list_images: Method to list all Docker images.
inspect_image: Method to inspect a specific image.
pull_image: Method to pull an image from a Docker registry.
push_image: Method to push an image to a Docker registry.
Note
Ensure that the Docker daemon is running and accessible at the specified URL.
Make sure to have the necessary permissions to interact with the Docker daemon and manage containers and images.
DockerSwarmManager is a utility for managing Docker Swarm services, including creating, inspecting, updating, and removing services. It extends DockerResourceManager to provide swarm-specific functionalities and commands via a command-line interface (CLI).
The manager interacts with the Docker Swarm API, offering a convenient way to manage Swarm services, nodes, and other swarm-related tasks from the command line.
CLI Usage
genius docker swarm sub-command
Sub-commands
list_nodes: List all nodes in the Docker Swarm. genius docker swarm list_nodes
inspect_node: Inspect a specific Swarm node by its ID. genius docker swarm inspect_node <node_id>
create_service: Create a new service in the Docker Swarm with comprehensive specifications. genius docker swarm create_service [options]
list_services: List all services in the Docker Swarm. genius docker swarm list_services
inspect_service: Inspect a specific service by its ID. genius docker swarm inspect_service <service_id>
update_service: Update an existing service with new parameters. genius docker swarm update_service <service_id> [options]
remove_service: Remove a service from the Docker Swarm. genius docker swarm remove_service <service_id>
service_logs: Retrieve logs of a Docker Swarm service. genius docker swarm service_logs <service_id> [--tail] [--follow]
scale_service: Scale a service to a specified number of replicas. genius docker swarm scale_service <service_id> <replicas>
Each sub-command supports various options to specify the details of the swarm node or service operation. These options include node and service IDs, image and command specifications for services, environment variables, resource limits, and much more.
Attributes:
Name Type Description swarm_client
The Docker Swarm client connection to interact with the Docker Swarm API.
log
Logger for the class to log information, warnings, and errors.
console
Rich console object to print formatted and styled outputs.
Methods
connect_to_swarm: Method to establish a connection to the Docker Swarm.
list_nodes: Method to list all nodes in the Docker Swarm.
inspect_node: Method to inspect details of a specific Swarm node.
create_service: Method to create a new service with given specifications.
list_services: Method to list all services in the Docker Swarm.
inspect_service: Method to inspect a specific service.
update_service: Method to update an existing service with new parameters.
remove_service: Method to remove a service from the Docker Swarm.
get_service_logs: Method to retrieve logs of a Docker Swarm service.
scale_service: Method to scale a service to a specified number of replicas.
Note
Ensure that the Docker Swarm is initialized and running.
Make sure to have the necessary permissions to interact with the Docker Swarm and manage services and nodes.
\ud83d\ude80 The CronJob class is responsible for managing Kubernetes CronJobs. It extends the Job class and provides additional functionalities specific to Kubernetes CronJobs.
\ud83d\ude80 The Job class is responsible for managing Kubernetes Jobs. It extends the Deployment class and provides additional functionalities specific to Kubernetes Jobs.
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/arangodb/#geniusrise_databases.arangodb.ArangoDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/arangodb/#geniusrise_databases.arangodb.ArangoDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/athena/#geniusrise_databases.athena.Athena.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/athena/#geniusrise_databases.athena.Athena.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/azure_table/#geniusrise_databases.azure_table.AzureTableStorage.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/azure_table/#geniusrise_databases.azure_table.AzureTableStorage.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/bigquery/#geniusrise_databases.bigquery.BigQuery.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/bigquery/#geniusrise_databases.bigquery.BigQuery.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/bigtable/#geniusrise_databases.bigtable.Bigtable.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/bigtable/#geniusrise_databases.bigtable.Bigtable.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/cassandra/#geniusrise_databases.cassandra.Cassandra.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/cassandra/#geniusrise_databases.cassandra.Cassandra.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/cloud_sql/#geniusrise_databases.cloud_sql.GoogleCloudSQL.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/cloud_sql/#geniusrise_databases.cloud_sql.GoogleCloudSQL.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/cockroach/#geniusrise_databases.cockroach.CockroachDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/cockroach/#geniusrise_databases.cockroach.CockroachDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/cosmosdb/#geniusrise_databases.cosmosdb.CosmosDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/cosmosdb/#geniusrise_databases.cosmosdb.CosmosDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/couchbase/#geniusrise_databases.couchbase.Couchbase.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/couchbase/#geniusrise_databases.couchbase.Couchbase.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/db2/#geniusrise_databases.db2.DB2.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/db2/#geniusrise_databases.db2.DB2.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/documentdb/#geniusrise_databases.documentdb.DocumentDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/documentdb/#geniusrise_databases.documentdb.DocumentDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/dynamodb/#geniusrise_databases.dynamodb.DynamoDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/dynamodb/#geniusrise_databases.dynamodb.DynamoDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/elasticsearch/#geniusrise_databases.elasticsearch.Elasticsearch.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/elasticsearch/#geniusrise_databases.elasticsearch.Elasticsearch.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/firestore/#geniusrise_databases.firestore.Firestore.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/firestore/#geniusrise_databases.firestore.Firestore.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/graphite/#geniusrise_databases.graphite.Graphite.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/graphite/#geniusrise_databases.graphite.Graphite.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/hbase/#geniusrise_databases.hbase.HBase.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/hbase/#geniusrise_databases.hbase.HBase.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/influxdb/#geniusrise_databases.influxdb.InfluxDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/influxdb/#geniusrise_databases.influxdb.InfluxDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/kairosdb/#geniusrise_databases.kairosdb.KairosDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/kairosdb/#geniusrise_databases.kairosdb.KairosDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/keyspaces/#geniusrise_databases.keyspaces.AWSKeyspaces.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/keyspaces/#geniusrise_databases.keyspaces.AWSKeyspaces.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/ldap/#geniusrise_databases.ldap.LDAP.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/ldap/#geniusrise_databases.ldap.LDAP.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/memsql/#geniusrise_databases.memsql.MemSQL.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/memsql/#geniusrise_databases.memsql.MemSQL.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/mongodb/#geniusrise_databases.mongodb.MongoDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/mongodb/#geniusrise_databases.mongodb.MongoDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/mysql/#geniusrise_databases.mysql.MySQL.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/mysql/#geniusrise_databases.mysql.MySQL.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/neo4j/#geniusrise_databases.neo4j.Neo4j.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/neo4j/#geniusrise_databases.neo4j.Neo4j.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/nuodb/#geniusrise_databases.nuodb.NuoDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/nuodb/#geniusrise_databases.nuodb.NuoDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/opentsdb/#geniusrise_databases.opentsdb.OpenTSDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/opentsdb/#geniusrise_databases.opentsdb.OpenTSDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/oracle/#geniusrise_databases.oracle.Oracle.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/oracle/#geniusrise_databases.oracle.Oracle.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/postgres/#geniusrise_databases.postgres.PostgreSQL.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/postgres/#geniusrise_databases.postgres.PostgreSQL.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/presto/#geniusrise_databases.presto.Presto.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/presto/#geniusrise_databases.presto.Presto.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/redis/#geniusrise_databases.redis.Redis.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/redis/#geniusrise_databases.redis.Redis.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/riak/#geniusrise_databases.riak.Riak.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/riak/#geniusrise_databases.riak.Riak.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/spanner/#geniusrise_databases.spanner.Spanner.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/spanner/#geniusrise_databases.spanner.Spanner.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/sql_server/#geniusrise_databases.sql_server.SQLServer.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/sql_server/#geniusrise_databases.sql_server.SQLServer.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/sqlite/#geniusrise_databases.sqlite.SQLite.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/sqlite/#geniusrise_databases.sqlite.SQLite.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/sybase/#geniusrise_databases.sybase.Sybase.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/sybase/#geniusrise_databases.sybase.Sybase.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/teradata/#geniusrise_databases.teradata.Teradata.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/teradata/#geniusrise_databases.teradata.Teradata.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/tidb/#geniusrise_databases.tidb.TiDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/tidb/#geniusrise_databases.tidb.TiDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/timescaledb/#geniusrise_databases.timescaledb.TimescaleDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/timescaledb/#geniusrise_databases.timescaledb.TimescaleDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/vertica/#geniusrise_databases.vertica.Vertica.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/vertica/#geniusrise_databases.vertica.Vertica.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/voltdb/#geniusrise_databases.voltdb.VoltDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/voltdb/#geniusrise_databases.voltdb.VoltDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The Geniusrise framework is designed to provide a modular, scalable, and interoperable system for orchestrating machine learning workflows, particularly in the context of Large Language Models (LLMs). The architecture is built around the core concept of a Task, which represents a discrete unit of work. This document provides an overview of the architecture, detailing the primary components and their interactions.
A task is the fundamental unit of work in the Geniusrise framework. It represents a specific operation or computation and can run for an arbitrary amount of time, performing any amount of work.
State Managers play a pivotal role in maintaining the state of tasks. They ensure that the progress and status of tasks are tracked, especially in distributed environments. Geniusrise offers various types of State Managers:
DynamoDBStateManager: Interfaces with Amazon DynamoDB.
InMemoryStateManager: Maintains state within the application's memory.
PostgresStateManager: Interfaces with PostgreSQL databases.
RedisStateManager: Interfaces with Redis in-memory data structure store.
State Managers store data in various locations, allowing organizations to connect dashboards to these storage systems for real-time monitoring and analytics. This centralized storage and reporting mechanism ensures that stakeholders have a unified view of task states.
Data Managers are responsible for handling the input and output data for tasks. They implement various data operations methods that tasks can leverage to ingest or save data during their runs. Data Managers can be categorized based on their function and data processing type:
Data Managers manage data partitioning for both batch and streaming data. By adhering to common data patterns, they enable the system's components to operate independently, fostering the creation of intricate networks of tasks. This independence, while allowing for flexibility and scalability, ensures that cascading failures in one component don't necessarily compromise the entire system.
Model Managers oversee model operations, ensuring that models are saved, loaded, and managed. They can be of two primary types:
S3ModelManager: Interfaces with Amazon S3 for model storage.
WANDBModelManager: Interfaces with Weights & Biases for model versioning.
GitModelManager: Interfaces with Git repositories for versioning of models.
2ecbac4f-84fa-4d78-8941-6a383e41383d
"},{"location":"guides/architecture/#spouts-and-bolts","title":"Spouts and Bolts","text":"
At the heart of the Geniusrise framework are two primary component types: spouts and bolts.
Spouts: These are tasks responsible for ingesting data from various sources. Depending on the output type, spouts can either produce streaming output or batch output.
Batch: Runs periodically, Produces data as a batch output.
Stream: Runs forever, produces data into a streaming output.
Bolts: Bolts are tasks that take in data, process it, and produce output. They can be categorized based on their input and output types:
Stream-Stream: Reads streaming data and produces streaming output.
Stream-Batch: Reads streaming data and produces batch output.
Batch-Stream: Reads batch data and produces streaming output.
Batch-Batch: Reads batch data and produces batch output.
Runners are the backbone of the Geniusrise framework, ensuring that tasks are executed seamlessly across various platforms. They encapsulate the environment and resources required for task execution, abstracting away the underlying complexities. Geniusrise offers the following runners:
Local Runner: Executes tasks directly on a local machine, ideal for development and testing.
Docker Runner: Runs tasks within Docker containers, ensuring a consistent and isolated environment.
Kubernetes Runner: Deploys tasks on Kubernetes clusters, leveraging its scalability and orchestration capabilities.
Airflow Runner: Integrates with Apache Airflow, allowing for complex workflow orchestration and scheduling.
ECS Runner: Executes tasks on AWS ECS, providing a managed container service.
Batch Runner: Optimized for batch computing workloads on platforms like AWS Batch.
: Choose the type of output data: batch or streaming.
{none,redis,postgres,dynamodb,prometheus}
: Select the type of state manager: none, redis, postgres, or dynamodb.
method_name
: The name of the method to execute on the spout.
Options genius TestSpoutCtlSpout rise
--buffer_size BUFFER_SIZE: Specify the size of the buffer. --output_folder OUTPUT_FOLDER: Specify the directory where output files should be stored temporarily
--output_kafka_topic OUTPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --output_kafka_cluster_connection_string OUTPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --output_s3_bucket OUTPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --output_s3_folder OUTPUT_S3_FOLDER: Indicate the S3 folder for output storage. --redis_host REDIS_HOST: Enter the host address for the Redis server. --redis_port REDIS_PORT: Enter the port number for the Redis server. --redis_db REDIS_DB: Specify the Redis database to be used. --postgres_host POSTGRES_HOST: Enter the host address for the PostgreSQL server. --postgres_port POSTGRES_PORT: Enter the port number for the PostgreSQL server. --postgres_user POSTGRES_USER: Provide the username for the PostgreSQL server. --postgres_password POSTGRES_PASSWORD: Provide the password for the PostgreSQL server. --postgres_database POSTGRES_DATABASE: Specify the PostgreSQL database to be used. --postgres_table POSTGRES_TABLE: Specify the PostgreSQL table to be used. --dynamodb_table_name DYNAMODB_TABLE_NAME: Provide the name of the DynamoDB table. --dynamodb_region_name DYNAMODB_REGION_NAME: Specify the AWS region for DynamoDB. --prometheus_gateway PROMETHEUS_GATEWAY: Specify the prometheus gateway URL. --args ...: Additional keyword arguments to pass to the spout.
: Choose the type of output data: batch or streaming.
{none,redis,postgres,dynamodb,prometheus}
: Select the type of state manager: none, redis, postgres, or dynamodb.
{k8s}
: Choose the type of deployment.
method_name
: The name of the method to execute on the spout.
Options genius TestSpoutCtlSpout deploy
--buffer_size BUFFER_SIZE: Specify the size of the buffer. --output_folder OUTPUT_FOLDER: Specify the directory where output files should be stored temporarily
--output_kafka_topic OUTPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --output_kafka_cluster_connection_string OUTPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --output_s3_bucket OUTPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --output_s3_folder OUTPUT_S3_FOLDER: Indicate the S3 folder for output storage. --redis_host REDIS_HOST: Enter the host address for the Redis server. --redis_port REDIS_PORT: Enter the port number for the Redis server. --redis_db REDIS_DB: Specify the Redis database to be used. --postgres_host POSTGRES_HOST: Enter the host address for the PostgreSQL server. --postgres_port POSTGRES_PORT: Enter the port number for the PostgreSQL server. --postgres_user POSTGRES_USER: Provide the username for the PostgreSQL server. --postgres_password POSTGRES_PASSWORD: Provide the password for the PostgreSQL server. --postgres_database POSTGRES_DATABASE: Specify the PostgreSQL database to be used. --postgres_table POSTGRES_TABLE: Specify the PostgreSQL table to be used. --dynamodb_table_name DYNAMODB_TABLE_NAME: Provide the name of the DynamoDB table. --dynamodb_region_name DYNAMODB_REGION_NAME: Specify the AWS region for DynamoDB. --prometheus_gateway PROMETHEUS_GATEWAY: Specify the prometheus gateway URL. --k8s_kind {deployment,service,job,cron_job}: Choose the type of kubernetes resource. --k8s_name K8S_NAME: Name of the Kubernetes resource. --k8s_image K8S_IMAGE: Docker image for the Kubernetes resource. --k8s_replicas K8S_REPLICAS: Number of replicas. --k8s_env_vars K8S_ENV_VARS: Environment variables as a JSON string. --k8s_cpu K8S_CPU: CPU requirements. --k8s_memory K8S_MEMORY: Memory requirements. --k8s_storage K8S_STORAGE: Storage requirements. --k8s_gpu K8S_GPU: GPU requirements. --k8s_kube_config_path K8S_KUBE_CONFIG_PATH: Name of the Kubernetes cluster local config. --k8s_api_key K8S_API_KEY: GPU requirements. --k8s_api_host K8S_API_HOST: GPU requirements. --k8s_verify_ssl K8S_VERIFY_SSL: GPU requirements. --k8s_ssl_ca_cert K8S_SSL_CA_CERT: GPU requirements. --k8s_cluster_name K8S_CLUSTER_NAME: Name of the Kubernetes cluster. --k8s_context_name K8S_CONTEXT_NAME: Name of the kubeconfig context. --k8s_namespace K8S_NAMESPACE: Kubernetes namespace. --k8s_labels K8S_LABELS: Labels for Kubernetes resources, as a JSON string. --k8s_annotations K8S_ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --k8s_port K8S_PORT: Port to run the spout on as a service. --k8s_target_port K8S_TARGET_PORT: Port to expose the spout on as a service. --k8s_schedule K8S_SCHEDULE: Schedule to run the spout on as a cron job. --args ...: Additional keyword arguments to pass to the spout.
: Choose the type of input data: batch or streaming.
{batch,streaming,stream_to_batch}
: Choose the type of output data: batch or streaming.
{none,redis,postgres,dynamodb,prometheus}
: Select the type of state manager: none, redis, postgres, or dynamodb.
method_name
: The name of the method to execute on the bolt.
Options genius TestBoltCtlBolt rise
--buffer_size BUFFER_SIZE: Specify the size of the buffer. --input_folder INPUT_FOLDER: Specify the directory where output files should be stored temporarily
--input_kafka_topic INPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --input_kafka_cluster_connection_string INPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --input_kafka_consumer_group_id INPUT_KAFKA_CONSUMER_GROUP_ID: Kafka consumer group id to use. --input_s3_bucket INPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --input_s3_folder INPUT_S3_FOLDER: Indicate the S3 folder for output storage. --output_folder OUTPUT_FOLDER: Specify the directory where output files should be stored temporarily
--output_kafka_topic OUTPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --output_kafka_cluster_connection_string OUTPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --output_s3_bucket OUTPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --output_s3_folder OUTPUT_S3_FOLDER: Indicate the S3 folder for output storage. --redis_host REDIS_HOST: Enter the host address for the Redis server. --redis_port REDIS_PORT: Enter the port number for the Redis server. --redis_db REDIS_DB: Specify the Redis database to be used. --postgres_host POSTGRES_HOST: Enter the host address for the PostgreSQL server. --postgres_port POSTGRES_PORT: Enter the port number for the PostgreSQL server. --postgres_user POSTGRES_USER: Provide the username for the PostgreSQL server. --postgres_password POSTGRES_PASSWORD: Provide the password for the PostgreSQL server. --postgres_database POSTGRES_DATABASE: Specify the PostgreSQL database to be used. --postgres_table POSTGRES_TABLE: Specify the PostgreSQL table to be used. --dynamodb_table_name DYNAMODB_TABLE_NAME: Provide the name of the DynamoDB table. --dynamodb_region_name DYNAMODB_REGION_NAME: Specify the AWS region for DynamoDB. --prometheus_gateway PROMETHEUS_GATEWAY: Specify the prometheus gateway URL. --args ...: Additional keyword arguments to pass to the bolt.
: Choose the type of input data: batch or streaming.
{batch,streaming,stream_to_batch}
: Choose the type of output data: batch or streaming.
{none,redis,postgres,dynamodb,prometheus}
: Select the type of state manager: none, redis, postgres, or dynamodb.
{k8s}
: Choose the type of deployment.
method_name
: The name of the method to execute on the spout.
Options genius TestBoltCtlBolt deploy
--buffer_size BUFFER_SIZE: Specify the size of the buffer. --input_folder INPUT_FOLDER: Specify the directory where output files should be stored temporarily
--input_kafka_topic INPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --input_kafka_cluster_connection_string INPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --input_kafka_consumer_group_id INPUT_KAFKA_CONSUMER_GROUP_ID: Kafka consumer group id to use. --input_s3_bucket INPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --input_s3_folder INPUT_S3_FOLDER: Indicate the S3 folder for output storage. --output_folder OUTPUT_FOLDER: Specify the directory where output files should be stored temporarily
--output_kafka_topic OUTPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --output_kafka_cluster_connection_string OUTPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --output_s3_bucket OUTPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --output_s3_folder OUTPUT_S3_FOLDER: Indicate the S3 folder for output storage. --redis_host REDIS_HOST: Enter the host address for the Redis server. --redis_port REDIS_PORT: Enter the port number for the Redis server. --redis_db REDIS_DB: Specify the Redis database to be used. --postgres_host POSTGRES_HOST: Enter the host address for the PostgreSQL server. --postgres_port POSTGRES_PORT: Enter the port number for the PostgreSQL server. --postgres_user POSTGRES_USER: Provide the username for the PostgreSQL server. --postgres_password POSTGRES_PASSWORD: Provide the password for the PostgreSQL server. --postgres_database POSTGRES_DATABASE: Specify the PostgreSQL database to be used. --postgres_table POSTGRES_TABLE: Specify the PostgreSQL table to be used. --dynamodb_table_name DYNAMODB_TABLE_NAME: Provide the name of the DynamoDB table. --dynamodb_region_name DYNAMODB_REGION_NAME: Specify the AWS region for DynamoDB. --prometheus_gateway PROMETHEUS_GATEWAY: Specify the prometheus gateway URL. --k8s_kind {deployment,service,job,cron_job}: Choose the type of kubernetes resource. --k8s_name K8S_NAME: Name of the Kubernetes resource. --k8s_image K8S_IMAGE: Docker image for the Kubernetes resource. --k8s_replicas K8S_REPLICAS: Number of replicas. --k8s_env_vars K8S_ENV_VARS: Environment variables as a JSON string. --k8s_cpu K8S_CPU: CPU requirements. --k8s_memory K8S_MEMORY: Memory requirements. --k8s_storage K8S_STORAGE: Storage requirements. --k8s_gpu K8S_GPU: GPU requirements. --k8s_kube_config_path K8S_KUBE_CONFIG_PATH: Name of the Kubernetes cluster local config. --k8s_api_key K8S_API_KEY: GPU requirements. --k8s_api_host K8S_API_HOST: GPU requirements. --k8s_verify_ssl K8S_VERIFY_SSL: GPU requirements. --k8s_ssl_ca_cert K8S_SSL_CA_CERT: GPU requirements. --k8s_cluster_name K8S_CLUSTER_NAME: Name of the Kubernetes cluster. --k8s_context_name K8S_CONTEXT_NAME: Name of the kubeconfig context. --k8s_namespace K8S_NAMESPACE: Kubernetes namespace. --k8s_labels K8S_LABELS: Labels for Kubernetes resources, as a JSON string. --k8s_annotations K8S_ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --k8s_port K8S_PORT: Port to run the spout on as a service. --k8s_target_port K8S_TARGET_PORT: Port to expose the spout on as a service. --k8s_schedule K8S_SCHEDULE: Schedule to run the spout on as a cron job. --args ...: Additional keyword arguments to pass to the spout.
--spout SPOUT: Name of the specific spout to run. --bolt BOLT: Name of the specific bolt to run. --file FILE: Path of the genius.yml file, default to .
Options genius rise
--spout SPOUT: Name of the specific spout to run. --bolt BOLT: Name of the specific bolt to run. --file FILE: Path of the genius.yml file, default to .
usage: genius pod [-h] {status,show,describe,logs} ...
POSITIONAL ARGUMENTS genius pod
genius pod status
: Get the status of the Kubernetes pod.
genius pod show
: List all pods.
genius pod describe
: Describe a pod.
genius pod logs
: Get the logs of a pod.
"},{"location":"guides/cli/#command-genius-pod-status","title":"Command: genius pod status","text":"
usage: genius pod status [-h] [--kube_config_path KUBE_CONFIG_PATH] [--cluster_name CLUSTER_NAME] [--context_name CONTEXT_NAME] [--namespace NAMESPACE] [--labels LABELS] [--annotations ANNOTATIONS] [--api_key API_KEY] [--api_host API_HOST] [--verify_ssl VERIFY_SSL] [--ssl_ca_cert SSL_CA_CERT] name
name
: Name of the Kubernetes pod.
Options genius pod status
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-pod-show","title":"Command: genius pod show","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-pod-describe","title":"Command: genius pod describe","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-pod-logs","title":"Command: genius pod logs","text":"
--follow FOLLOW: Whether to follow the logs. --tail TAIL: Number of lines to show from the end of the logs. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--replicas REPLICAS: Number of replicas. --env_vars ENV_VARS: Environment variables as a JSON string. --cpu CPU: CPU requirements. --memory MEMORY: Memory requirements. --storage STORAGE: Storage requirements. --gpu GPU: GPU requirements. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--replicas REPLICAS: Number of replicas. --port PORT: Service port. --target_port TARGET_PORT: Container target port. --env_vars ENV_VARS: Environment variables as a JSON string. --cpu CPU: CPU requirements. --memory MEMORY: Memory requirements. --storage STORAGE: Storage requirements. --gpu GPU: GPU requirements. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-service-delete","title":"Command: genius service delete","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-service-describe","title":"Command: genius service describe","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-service-show","title":"Command: genius service show","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--env_vars ENV_VARS: Environment variables as a JSON string. --cpu CPU: CPU requirements. --memory MEMORY: Memory requirements. --storage STORAGE: Storage requirements. --gpu GPU: GPU requirements. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--env_vars ENV_VARS: Environment variables as a JSON string. --cpu CPU: CPU requirements. --memory MEMORY: Memory requirements. --storage STORAGE: Storage requirements. --gpu GPU: GPU requirements. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--auth AUTH: Authentication credentials as a JSON string. --base_image BASE_IMAGE: The base image to use for the Docker container. --workdir WORKDIR: The working directory in the Docker container. --local_dir LOCAL_DIR: The local directory to copy into the Docker container. --packages [PACKAGES ...]: List of Python packages to install in the Docker container. --os_packages [OS_PACKAGES ...]: List of OS packages to install in the Docker container. --env_vars ENV_VARS: Environment variables to set in the Docker container.
The Geniusrise framework is built around loosely-coupled modules acting as a cohesive adhesive between distinct, modular components, much like how one would piece together Lego blocks. This design approach not only promotes flexibility but also ensures that each module or \"Lego block\" remains sufficiently independent. Such independence is crucial for diverse teams, each with its own unique infrastructure and requirements, to seamlessly build and manage their respective components.
Geniusrise comes with a sizable set of plugins which implement various features and integrations. The independence and modularity of the design enable sharing of these building blocks in the community.
Task: At its core, a task represents a discrete unit of work within the Geniusrise framework. Think of it as a singular action or operation that the system needs to execute. A task further manifests itself into a Bolt or a Spout as stated below.
Components of a Task: Each task is equipped with four components:
State Manager: This component is responsible for continuously monitoring and managing the task's state, ensuring that it progresses smoothly from initiation to completion and to report errors and ship logs into a central location.
Data Manager: As the name suggests, the Data Manager oversees the input and output data associated with a task, ensuring data integrity and efficient data flow. It also ensures data sanity follows partition semantics and isolation.
Runner: These are wrappers for executing a task on various platforms. Depending on the platform, the runner ensures that the task is executed seamlessly.
Task Classification: Tasks within the Geniusrise framework can be broadly classified into two categories:
Spout: If a task's primary function is to ingest or bring in data, it's termed as a 'spout'.
Bolt: For tasks that don't primarily ingest data but perform other operations, they are termed 'bolts'.
The beauty of the Geniusrise framework lies in its adaptability. Developers can script their workflow components once and have the freedom to deploy them across various platforms. To facilitate this, Geniusrise offers:
Runners for Task Execution: Geniusrise is equipped with a diverse set of runners, each tailored for different platforms, ensuring that tasks can be executed almost anywhere:
On your local machine for quick testing and development.
Within Docker containers for isolated, reproducible environments.
On Kubernetes clusters for scalable, cloud-native deployments.
Using Apache Airflow for complex workflow orchestration. (Coming Soon).
On AWS ECS for containerized application management. (Coming Soon).
With AWS Batch for efficient batch computing workloads. (Coming Soon).
With Docker Swarm clusters as an alternative orchestrator to kubernetes. (Coming Soon).
This document delves into the core components and concepts that make up the Geniusrise framework.
Because of the very loose coupling of the components, though the framework can be used to build very complex networks with independently running nodes, it provides limited orchestration capability, like synchronous pipelines. An external orchestrator like airflow can be used in such cases to orchestrate geniusrise components.
This guide provides comprehensive instructions on how to deploy and manage resources in a Kubernetes cluster using the Geniusrise platform. The guide covers the following functionalities:
"},{"location":"guides/deployment/#managing-pods","title":"Managing Pods","text":""},{"location":"guides/deployment/#checking-pod-status","title":"Checking Pod Status","text":"
To get the status of a specific pod:
genius k8s status my-pod-name --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#listing-all-pods","title":"Listing All Pods","text":"
To list all the pods in the current namespace:
genius k8s show --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#describing-a-pod","title":"Describing a Pod","text":"
"},{"location":"guides/deployment/#managing-deployments","title":"Managing Deployments","text":""},{"location":"guides/deployment/#creating-a-new-deployment","title":"Creating a New Deployment","text":"
"},{"location":"guides/deployment/#managing-services","title":"Managing Services","text":""},{"location":"guides/deployment/#creating-a-new-service","title":"Creating a New Service","text":"
"},{"location":"guides/deployment/#deleting-a-service","title":"Deleting a Service","text":"
To delete a service:
genius service delete --name example-service --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#describing-a-service","title":"Describing a Service","text":"
To describe a specific service:
genius service describe --name example-service --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#listing-all-services","title":"Listing All Services","text":"
To list all services:
genius service show --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#managing-jobs","title":"Managing Jobs","text":""},{"location":"guides/deployment/#creating-a-new-job","title":"Creating a New Job","text":"
genius job status --name example-job --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#managing-cron-jobs","title":"Managing Cron Jobs","text":""},{"location":"guides/deployment/#creating-a-new-cron-job","title":"Creating a New Cron Job","text":"
To create a new cron job, you can use the create_cronjob sub-command. You'll need to specify the name, Docker image, command to run, and the cron schedule.
"},{"location":"guides/deployment/#advanced-features-for-cron-jobs","title":"Advanced Features for Cron Jobs","text":""},{"location":"guides/deployment/#environment-variables_1","title":"Environment Variables","text":"
You can pass environment variables to your cron jobs like so:
SNOMED-CT: is a knowledge graph of standard medical terminology
IHTSDO: a standards body for medical terminologies in a number of countries.
UMLS: unified medical language system is a set of files and software that brings together many health and biomedical vocabularies and standards together.
"},{"location":"guides/dev_cycle/#strategy-1-named-entity-recognition","title":"Strategy 1: Named entity recognition","text":""},{"location":"guides/dev_cycle/#1-create-a-labelled-dataset","title":"1. Create a labelled dataset","text":"
We need a corpus of documents with medical terms labeled. For example, we could use wikipedia + wikidata to build such a dataset, given entities in wikipedia are linked and indexed in the wikidata knowledge graph. Reference: Building a Massive Corpus for Named Entity Recognition using Free Open Data Sources. We could also annotate medical datasets like MIMIC-III annotated with SNOMED-CT based MedCAT which is a medical annotation tool developed on the knowledge graph of medical terminology (SNOMED-CT), as it would be more pertinent to our usecase, reference: DNER Clinical (named entity recognition) from free clinical text to Snomed-CT concept
"},{"location":"guides/dev_cycle/#2-train-a-model-on-the-ner-dataset","title":"2. Train a model on the NER dataset","text":"
We could choose a large language model and train the model on the NER fine-tuning task. The model would then be able to recognize and tag medical terms in any given text data.
We use an LLM to create a vectorized layer over SNOMED-CT. This layer can be used to semantically search for \"seed\" nodes in the graph. We can then use these seed nodes to traverse nodes a few hops adjacent to the seed nodes.
We use the knowledge graph search results to not only annotate each node seen in the EHR document, but also add additional information about those nodes derived from its adjacent nodes. But first, we also need to make sure that we query the right information instead of simply vectorized chunks and throwing it at semantic search. We would need a \"traditional\" pipeline for this - lemmatization followed by POS tagging. We use both proper nouns and out of vocabulary words as search query terms.
"},{"location":"guides/dev_cycle/#preparing-the-knowledge-graph","title":"Preparing the knowledge graph","text":"
Lets prepare the knowledge graph by vectorizing each node's knowledge into a vectorized flat memory. This is a periodic activity that one needs to do whenever a new version of SNOMED-CT is released (typically bi-annually).
We use the international version of SNOMED-CT from https://www.nlm.nih.gov/healthit/snomedct/international.html.
mkdir data\ncd data\n
Go to UMLS or IHTSDO website, register, agree to the agreements and after approval, download the knowledge graph.
Geniusrise is composed of the core framework and various plugins that implement specific tasks. The core has to be installed first, and after that selected plugins can be installed as and when required.
Geniusrise containers are available on Docker hub.
docker run -it --rm geniusrise/geniusrise:latest\n``` -->\n\n## Installing Plugins\n---\n\nGeniusrise offers a variety of plugins that act as composable lego blocks. To install a specific plugin, use the following format:\n\n```bash\npip install geniusrise-<plugin-name>\n
Replace <plugin-name> with the name of the desired plugin.
Available plugins are:
geniusrise-text: bolts for text models
geniusrise-vision: bolts for vision models
geniusrise-audio: bolts for audio models
geniusrise-openai: bolts for openai
geniusrise-listeners: spouts for streaming event listeners
geniusrise-databases: spouts for databases
Please visit https://github.com/geniusrise for a complete list of available plugins.
In this example, the --config=my_config.yaml would be used to read the common arguments from the YAML file, and the rest of the arguments would be taken from the command line.
Lets create a workspace for local experimentation. We will not build anything here, just try to use whatever components are available. This is what a low-code workflow could look like.
Lets create a workflow in which:
A web server listens for all kinds of HTTP events.
Clients send the following information to the server:
HTTP request
Response and response status code
The server buffers events in batches of 1000 and uploads them on to s3.
Train a small LLM model on the data to be used to predict whether the request was valid.
A representation of the process using a sequence diagram:
3df6131b-2989-469b-9203-56d38b88b3ee
This model could be used to predict if a request will fail before serving it. It could also be used to classify requests as malicious etc.
\ud83d\ude80 Initialized Task with ID: Webhookaca9cb67-5c41-420c-9445-cf0015d9d866\n [17/Sep/2023:14:00:18] ENGINE Bus STARTING\nCherryPy Checker:\nThe Application mounted at '' has an empty config.\n\n[17/Sep/2023:14:00:18] ENGINE Started monitor thread 'Autoreloader'.\n [17/Sep/2023:14:00:18] ENGINE Serving on http://0.0.0.0:8080\n [17/Sep/2023:14:00:18] ENGINE Bus STARTED\n
while true; do\n# Generate a random customer ID\ncustomer_id=$(( RANDOM % 10000001 ))\n# Determine the status code based on the customer ID\nif [ $customer_id -gt 10000000 ]; then\nstatus_code=\"1\"\nelif [ $customer_id -le 10000 ]; then\nstatus_code=\"1\"\nelse\nstatus_code=\"0\"\nfi\n# Make the API call\ncurl --header \"Content-Type: application/json\" \\\n--request POST \\\n--data \"{\\\"text\\\":\\\"GET /api/v1/customer/$customer_id\\\",\\\"label\\\":\\\"$status_code\\\"}\" \\\nhttp://localhost:8080/application-1-tag-a-tag-b-whatever\ndone\n
Verify that the data is being dumped in the right place with the correct format:
Now lets test the second leg of this, the model. Since we want to use the model for predicting the status code given the data, we will use classification as our task for fine-tuning the model.
Lets use the bert-base-uncased model for now, as it is small enough to run on a CPU on a laptop. We also create a model on huggingface hub to store the model once it is trained: ixaxaar/geniusrise-api-status-code-prediction.
\ud83d\ude80 Initialized Task with ID: HuggingFaceClassificationFineTuner772627a0-43a5-4f9d-9b0f-4362d69ba08c\n Found credentials in shared credentials file: ~/.aws/credentials\nSome weights of BertForSequenceClassification were not initialized from the model checkpoint at bert-base-uncased and are newly initialized: ['classifier.bias', 'classifier.weight']\nYou should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n Loading dataset from /tmp/tmp3h3wav4h/train\n New labels detected, ignore if fine-tuning\nMap: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 300/300 [00:00<00:00, 4875.76 examples/s]\n{'train_runtime': 13.3748, 'train_samples_per_second': 44.861, 'train_steps_per_second': 22.43, 'train_loss': 0.6400579833984374, 'epoch': 2.0}\n100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 300/300 [00:13<00:00, 22.43it/s]\npytorch_model.bin: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 438M/438M [01:29<00:00, 4.88MB/s]\n Successfully executed the bolt method: fine_tune \ud83d\udc4d\n
You'll see a progress bar at the bottom, on completion, a pull request will appear on huggingface hub. Here is the model we trained: https://huggingface.co/ixaxaar/geniusrise-api-status-code-prediction.
"},{"location":"guides/packaging/#complex-examples","title":"Complex Examples","text":""},{"location":"guides/packaging/#1-uploading-to-ecr-with-custom-base-image-and-packages","title":"1. Uploading to ECR with Custom Base Image and Packages","text":"
This example demonstrates how to upload a Docker image to ECR with a custom base image and additional Python packages.
"},{"location":"guides/packaging/#2-uploading-to-dockerhub-with-environment-variables-and-working-directory","title":"2. Uploading to DockerHub with Environment Variables and Working Directory","text":"
This example shows how to upload a Docker image to DockerHub with custom environment variables and a specific working directory.
"},{"location":"guides/packaging/#3-uploading-to-acr-with-multiple-local-directories","title":"3. Uploading to ACR with Multiple Local Directories","text":"
In this example, we upload a Docker image to Azure Container Registry (ACR) and specify multiple local directories to be copied into the Docker container.
# First, create a Dockerfile that copies multiple directories\n# Then use the following command\ngenius docker package multi_dir_app acr \\\n--auth '{\"acr_username\": \"username\", \"acr_password\": \"password\", \"acr_login_server\": \"login_server\"}' \\\n--local_dir \"./app ./config\"\n
"},{"location":"guides/packaging/#4-uploading-to-gcr-with-custom-base-image-packages-and-os-packages","title":"4. Uploading to GCR with Custom Base Image, Packages, and OS Packages","text":"
This example demonstrates how to upload a Docker image to Google Container Registry (GCR) with a custom base image, Python packages, and OS packages.
"},{"location":"guides/packaging/#5-uploading-to-quay-with-all-customizations","title":"5. Uploading to Quay with All Customizations","text":"
This example shows how to upload a Docker image to Quay with all available customizations like base image, working directory, local directory, Python packages, OS packages, and environment variables.
The TTGO T-Camera Plus is a unique ESP32 module featuring a built-in camera and display. It's designed for applications that require direct image capture and display capabilities without the need for external screens or cameras.
CPU: Dual-core Tensilica LX6 microprocessor up to 240 MHz
Memory: 520 KB SRAM, 4 MB PSRAM
Connectivity: Wi-Fi (802.11 b/g/n), Bluetooth (Classic and BLE)
Camera: OV2640 camera module, 2 Megapixels
Display: 1.3-inch OLED display
Extras: Fish-eye lens, optional MPU6050 module for motion sensing
"},{"location":"guides/pin/#seeed-studio-xiao","title":"Seeed Studio XIAO","text":"
Seeed Studio XIAO ESP32C3 is a mini but powerful module. It's part of the Seeed Studio XIAO series, known for its compact design and reliability in various IoT projects.
CPU: RISC-V single-core processor, up to 160 MHz
Memory: 400 KB SRAM, 4 MB Flash
Connectivity: Wi-Fi (802.11 b/g/n), Bluetooth 5 (LE)
I/O Pins: Rich set of peripherals including GPIOs, UART, SPI, I2C, and more.
Size: Ultra-small form factor suitable for wearable devices and compact projects
We used a bunch of these peripherals wherever the boards did not have them. We usually chose a platform with at least a screen and a camera included and added these peripherals to them.
Power Supply: Ensure that all devices are powered appropriately. The XIAO and TTGO can be powered via USB or an external 3.3V power supply.
Common Ground: Make sure all components share a common ground connection.
Programming: Use the Arduino IDE or ESP-IDF for programming the ESP32 devices. Libraries specific to the peripherals (e.g., display, I2S microphone, and speaker) will be required.
I2S Library: For the INMP441 microphone, an I2S library suitable for ESP32 should be used to handle audio input.
Display Library: For the touchscreen display, a library compatible with the specific model will be needed for interfacing and graphics rendering.
"},{"location":"guides/yaml/#example-3-bolt-with-postgres-state-and-ecs-deployment","title":"Example 3: Bolt with Postgres State and ECS Deployment","text":"
"},{"location":"guides/yaml/#example-4-spout-with-s3-state-and-lambda-deployment","title":"Example 4: Spout with S3 State and Lambda Deployment","text":"
"},{"location":"guides/yaml/#example-5-bolt-with-dynamodb-state-and-fargate-deployment","title":"Example 5: Bolt with DynamoDB State and Fargate Deployment","text":"
"},{"location":"guides/yaml/#example-6-spout-and-bolt-with-azure-blob-storage-and-azure-functions","title":"Example 6: Spout and Bolt with Azure Blob Storage and Azure Functions","text":"
You can manage Kubernetes deployments using the genius CLI. Here are some example commands:
# Show pods in a namespace\ngenius pod show --namespace geniusrise --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise\n\n# Scale a deployment\ngenius pod scale --namespace geniusrise --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise --name testspout --replicas 3\n# Delete a deployment\ngenius pod delete --namespace geniusrise --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise --name testspout\n
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/activemq/#activemq.ActiveMQ.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/activemq/#activemq.ActiveMQ.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/amqp/#amqp.RabbitMQ.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/amqp/#amqp.RabbitMQ.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/grpc/#grpc.Grpc.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/grpc/#grpc.Grpc.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/http_polling/#http_polling.RESTAPIPoll.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/http_polling/#http_polling.RESTAPIPoll.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/kafka/#kafka.Kafka.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/kafka/#kafka.Kafka.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/kinesis/#kinesis.Kinesis.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/kinesis/#kinesis.Kinesis.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/mqtt/#mqtt.MQTT.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/mqtt/#mqtt.MQTT.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/quic/#quic.Quic.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/quic/#quic.Quic.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/redis_pubsub/#redis_pubsub.RedisPubSub.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/redis_pubsub/#redis_pubsub.RedisPubSub.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/redis_streams/#redis_streams.RedisStream.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/redis_streams/#redis_streams.RedisStream.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/sns/#sns.SNS.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/socket.io/#socketio.SocketIo.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/socket.io/#socketio.SocketIo.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/sqs/#sqs.SQS.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/udp/#udp.Udp.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/webhook/#webhook.Webhook.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/webhook/#webhook.Webhook.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/websocket/#websocket.Websocket.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/websocket/#websocket.Websocket.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/zeromq/#zeromq.ZeroMQ.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/zeromq/#zeromq.ZeroMQ.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The ConvertImage class is designed to convert images from one format to another. It takes an input folder containing images and an output format as arguments. The class iterates through each image file in the specified folder and converts it to the desired format. Additional options like quality and subsampling can be specified for lossy formats like 'JPG'.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ConvertImage/#geniusrise_ocr.readers.image.ConvertImage.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ConvertImage/#geniusrise_ocr.readers.image.ConvertImage.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
\ud83d\udcd6 Convert images in the given input folder to the specified output format.
Parameters:
Name Type Description Default output_formatstr
The format to convert images to ('PNG' or 'JPG').
required qualityOptional[int]
The quality of the output image for lossy formats like 'JPG'. Defaults to None.
NonesubsamplingOptional[int]
The subsampling factor for JPEG compression. Defaults to 0.
0
This method iterates through each image file in the specified folder, reads the image, and converts it to the specified output format. Additional parameters like quality and subsampling can be set for lossy formats.
The FineTunePix2Struct class is designed to fine-tune the Pix2Struct model on a custom OCR dataset. It supports three popular OCR dataset formats: COCO, ICDAR, and SynthText.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required model_namestr
The name of the Pix2Struct model to use. Default is \"google/pix2struct-large\".
'google/pix2struct-large'**kwargs
Additional keyword arguments.
{} Dataset Formats
COCO: Assumes a folder structure with an 'annotations.json' file containing image and text annotations.
ICDAR: Assumes a folder structure with 'Images' and 'Annotations' folders containing image files and XML annotation files respectively.
SynthText: Assumes a folder with image files and corresponding '.txt' files containing ground truth text.
"},{"location":"ocr/FineTunePix2Struct/#geniusrise_ocr.ocr.pix2struct.fine_tune.FineTunePix2Struct.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/FineTunePix2Struct/#geniusrise_ocr.ocr.pix2struct.fine_tune.FineTunePix2Struct.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
\ud83d\udcd6 Fine-tune the Pix2Struct model on a custom OCR dataset.
Parameters:
Name Type Description Default epochsint
Number of training epochs.
required batch_sizeint
Batch size for training.
required learning_ratefloat
Learning rate for the optimizer.
required dataset_formatstr
Format of the OCR dataset. Supported formats are \"coco\", \"icdar\", and \"synthtext\".
required use_cudabool
Whether to use CUDA for training. Default is False.
False
This method fine-tunes the Pix2Struct model using the images and annotations in the dataset specified by dataset_format. The fine-tuned model is saved to the specified output path.
"},{"location":"ocr/FineTuneTROCR/","title":"OCR API using trocr","text":"
The FineTuneTROCR class is designed to fine-tune the TROCR model on a custom OCR dataset. It supports three popular OCR dataset formats: COCO, ICDAR, and SynthText.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{} Dataset Formats
COCO: Assumes a folder structure with an 'annotations.json' file containing image and text annotations.
ICDAR: Assumes a folder structure with 'Images' and 'Annotations' folders containing image files and XML annotation files respectively.
SynthText: Assumes a folder with image files and corresponding '.txt' files containing ground truth text.
"},{"location":"ocr/FineTuneTROCR/#geniusrise_ocr.ocr.trocr.fine_tune.FineTuneTROCR.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/FineTuneTROCR/#geniusrise_ocr.ocr.trocr.fine_tune.FineTuneTROCR.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
\ud83d\udcd6 Fine-tune the TROCR model on a custom OCR dataset.
Parameters:
Name Type Description Default epochsint
Number of training epochs.
required batch_sizeint
Batch size for training.
required learning_ratefloat
Learning rate for the optimizer.
required dataset_formatstr
Format of the OCR dataset. Supported formats are \"coco\", \"icdar\", and \"synthtext\".
required use_cudabool
Whether to use CUDA for training. Default is False.
False
This method fine-tunes the TROCR model using the images and annotations in the dataset specified by dataset_format. The fine-tuned model is saved to the specified output path.
The ImageClassPredictor class classifies images using a pre-trained PyTorch model. It assumes that the input.input_folder contains sub-folders of images to be classified. The classified images are saved in output.output_folder, organized by their predicted labels.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ImageClassPredictor/#geniusrise_ocr.classification.predict.ImageClassPredictor.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/ImageClassPredictor/#geniusrise_ocr.classification.predict.ImageClassPredictor.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
\ud83d\udcd6 Classify images in the input sub-folders using a pre-trained PyTorch model.
Parameters:
Name Type Description Default classesstr
JSON string mapping class indices to labels.
required model_pathstr
Path to the pre-trained PyTorch model.
required use_cudabool
Whether to use CUDA for model inference. Default is False.
False
This method iterates through each image file in the specified sub-folders, applies the model, and classifies the image. The classified images are then saved in an output folder, organized by their predicted labels.
The ParseCBZCBR class is designed to process CBZ and CBR files, which are commonly used for comic books. It takes an input folder containing CBZ/CBR files as an argument and iterates through each file. For each file, it extracts the images and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseCBZCBR/#geniusrise_ocr.readers.cbz_cbr.ParseCBZCBR.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ParseCBZCBR/#geniusrise_ocr.readers.cbz_cbr.ParseCBZCBR.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The ParseDjvu class is designed to process DJVU files and classify them as either text-based or image-based. It takes an input folder containing DJVU files as an argument and iterates through each file. For each DJVU, it samples a few pages to determine the type of content it primarily contains. If the DJVU is text-based, the class extracts the text from each page and saves it as a JSON file. If the DJVU is image-based, it converts each page to a PNG image and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseDjvu/#geniusrise_ocr.readers.djvu.ParseDjvu.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
\ud83d\udcd6 Process DJVU files in the given input folder and classify them as text-based or image-based.
Parameters:
Name Type Description Default input_folderstr
The folder containing DJVU files to process.
None
This method iterates through each DJVU file in the specified folder, reads a sample of pages, and determines whether the DJVU is text-based or image-based. It then delegates further processing to _process_text_djvu or _process_image_djvu based on this determination.
The ParseEpub class is designed to process EPUB files and classify them as either text-based or image-based. It takes an input folder containing EPUB files as an argument and iterates through each file. For each EPUB, it samples a few items to determine the type of content it primarily contains. If the EPUB is text-based, the class extracts the text from each item and saves it as a JSON file. If the EPUB is image-based, it saves the images in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseEpub/#geniusrise_ocr.readers.epub.ParseEpub.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
\ud83d\udcd6 Process EPUB files in the given input folder and classify them as text-based or image-based.
Parameters:
Name Type Description Default input_folderstr
The folder containing EPUB files to process.
None
This method iterates through each EPUB file in the specified folder, reads a sample of items, and determines whether the EPUB is text-based or image-based. It then delegates further processing to _process_text_epub or _process_image_epub based on this determination.
The ParseMOBI class is designed to process MOBI files. It takes an input folder containing MOBI files as an argument and iterates through each file. For each file, it extracts the images and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseMOBI/#geniusrise_ocr.readers.mobi.ParseMOBI.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ParseMOBI/#geniusrise_ocr.readers.mobi.ParseMOBI.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The ParsePdf class is designed to process PDF files and classify them as either text-based or image-based. It takes an input folder containing PDF files as an argument and iterates through each file. For each PDF, it samples a few pages to determine the type of content it primarily contains. If the PDF is text-based, the class extracts the text from each page and saves it as a JSON file. If the PDF is image-based, it converts each page to a PNG image and saves them in a designated output folder.
Args:\n input (BatchInput): An instance of the BatchInput class for reading the data.\n output (BatchOutput): An instance of the BatchOutput class for saving the data.\n state (State): An instance of the State class for maintaining the state.\n **kwargs: Additional keyword arguments.\n
"},{"location":"ocr/ParsePdf/#geniusrise_ocr.readers.pdf.ParsePdf.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ParsePdf/#geniusrise_ocr.readers.pdf.ParsePdf.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
\ud83d\udcd6 Process PDF files in the given input folder and classify them as text-based or image-based.
Parameters:
Name Type Description Default input_folderstr
The folder containing PDF files to process.
None
This method iterates through each PDF file in the specified folder, reads a sample of pages, and determines whether the PDF is text-based or image-based. It then delegates further processing to _process_text_pdf or _process_image_pdf based on this determination.
The ParsePostScript class is designed to process PostScript files and classify them as either text-based or image-based. It takes an input folder containing PostScript files as an argument and iterates through each file. For each PostScript file, it converts it to PDF and samples a few pages to determine the type of content it primarily contains. If the PostScript is text-based, the class extracts the text from each page and saves it as a JSON file. If the PostScript is image-based, it converts each page to a PNG image and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParsePostScript/#geniusrise_ocr.readers.postscript.ParsePostScript.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
\ud83d\udcd6 Process PostScript files in the given input folder and classify them as text-based or image-based.
Parameters:
Name Type Description Default input_folderstr
The folder containing PostScript files to process.
None
This method iterates through each PostScript file in the specified folder, converts it to PDF, reads a sample of pages, and determines whether the PostScript is text-based or image-based. It then delegates further processing to _process_text_ps or _process_image_ps based on this determination.
The ParseXPS class is designed to process XPS files. It takes an input folder containing XPS files as an argument and iterates through each file. For each file, it extracts the images and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseXPS/#geniusrise_ocr.readers.xps.ParseXPS.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ParseXPS/#geniusrise_ocr.readers.xps.ParseXPS.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The Pix2StructImageOCR class performs OCR on images using Google's Pix2Struct model. It expects the input.input_folder to contain the images for OCR and saves the OCR results as JSON files in output.output_folder.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required model_namestr
The name of the Pix2Struct model to use. Default is \"google/pix2struct-large\".
'google/pix2struct-large'**kwargs
Additional keyword arguments.
{}"},{"location":"ocr/Pix2StructImageOCR/#geniusrise_ocr.ocr.pix2struct.bulk.Pix2StructImageOCR.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/Pix2StructImageOCR/#geniusrise_ocr.ocr.pix2struct.bulk.Pix2StructImageOCR.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
The Pix2StructImageOCRAPI class performs OCR on images using Google's Pix2Struct model. The class exposes an API endpoint for OCR on single images. The endpoint is accessible at /api/v1/ocr. The API takes a POST request with a JSON payload containing a base64 encoded image under the key image_base64. It returns a JSON response containing the OCR result under the key ocr_text.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required model_namestr
The name of the Pix2Struct model to use. Default is \"google/pix2struct-large\".
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/Pix2StructImageOCRAPI/#geniusrise_ocr.ocr.pix2struct.api.Pix2StructImageOCRAPI.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/Pix2StructImageOCRAPI/#geniusrise_ocr.ocr.pix2struct.api.Pix2StructImageOCRAPI.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
The TROCRImageOCR class performs OCR (Optical Character Recognition) on images using Microsoft's TROCR model. It expects the input.input_folder to contain the images for OCR and saves the OCR results as JSON files in output.output_folder.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/TROCRImageOCR/#geniusrise_ocr.ocr.trocr.bulk.TROCRImageOCR.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/TROCRImageOCR/#geniusrise_ocr.ocr.trocr.bulk.TROCRImageOCR.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
\ud83d\udcd6 Perform OCR on images in the input folder and save the OCR results as JSON files in the output folder.
This method iterates through each image file in input.input_folder, performs OCR using the TROCR model, and saves the OCR results as JSON files in output.output_folder.
Parameters:
Name Type Description Default kindstr
The kind of TROCR model to use. Default is \"printed\". Options are \"printed\" or \"handwritten\".
'printed'use_cudabool
Whether to use CUDA for model inference. Default is True.
True"},{"location":"ocr/TROCRImageOCRAPI/","title":"OCR API using trocr","text":"
The TROCRImageOCR class performs OCR (Optical Character Recognition) on images using Microsoft's TROCR model. The class exposes an API endpoint for OCR on single images. The endpoint is accessible at /api/v1/ocr. The API takes a POST request with a JSON payload containing a base64 encoded image under the key image_base64. It returns a JSON response containing the OCR result under the key ocr_text.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/TROCRImageOCRAPI/#geniusrise_ocr.ocr.trocr.api.TROCRImageOCRAPI.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/TROCRImageOCRAPI/#geniusrise_ocr.ocr.trocr.api.TROCRImageOCRAPI.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
The TrainImageClassifier class trains an image classifier using a ResNet-152 model. It assumes that the input.input_folder contains sub-folders named 'train' and 'test'. Each of these sub-folders should contain class-specific folders with images. The trained model is saved as 'model.pth' in output.output_folder.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/TrainImageClassifier/#geniusrise_ocr.classification.train.TrainImageClassifier.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/TrainImageClassifier/#geniusrise_ocr.classification.train.TrainImageClassifier.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
\ud83d\udcd6 Train an image classifier using a ResNet-152 model.
Parameters:
Name Type Description Default num_classesint
Number of classes of the images.
4epochsint
Number of training epochs. Default is 10.
10batch_sizeint
Batch size for training. Default is 32.
32learning_ratefloat
Learning rate for the optimizer. Default is 0.001.
0.001use_cudabool
Whether to use CUDA for model training. Default is False.
False
This method trains a ResNet-152 model using the images in the 'train' and 'test' sub-folders of input.input_folder. Each of these sub-folders should contain class-specific folders with images. The trained model is saved as 'model.pth' in output.output_folder.
"},{"location":"text/api/base/","title":"Base Fine Tuner","text":"
Bases: TextBulk
A class representing a Hugging Face API for generating text using a pre-trained language model.
Attributes:
Name Type Description modelAny
The pre-trained language model.
tokenizerAny
The tokenizer used to preprocess input text.
model_namestr
The name of the pre-trained language model.
model_revisionOptional[str]
The revision of the pre-trained language model.
tokenizer_namestr
The name of the tokenizer used to preprocess input text.
tokenizer_revisionOptional[str]
The revision of the tokenizer used to preprocess input text.
model_classstr
The name of the class of the pre-trained language model.
tokenizer_classstr
The name of the class of the tokenizer used to preprocess input text.
use_cudabool
Whether to use a GPU for inference.
quantizationint
The level of quantization to use for the pre-trained language model.
precisionstr
The precision to use for the pre-trained language model.
device_mapstr | Dict | None
The mapping of devices to use for inference.
max_memoryDict[int, str]
The maximum memory to use for inference.
torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model.
model_argsAny
Additional arguments to pass to the pre-trained language model.
Methods
text(**kwargs: Any) -> Dict[str, Any]: Generates text based on the given prompt and decoding strategy.
TextClassificationAPI leveraging Hugging Face's transformers for text classification tasks. This API provides an interface to classify text into various categories like sentiment, topic, intent, etc.
Attributes:
Name Type Description modelAutoModelForSequenceClassification
A Hugging Face model for sequence classification.
tokenizerAutoTokenizer
A tokenizer for preprocessing text.
hf_pipelinePipeline
A Hugging Face pipeline for text classification.
Methods
classify(self): Classifies text using the model and tokenizer. classification_pipeline(self): Classifies text using the Hugging Face pipeline. initialize_pipeline(self): Lazy initialization of the classification pipeline.
Accepts text input and returns classification results using the Hugging Face pipeline.
This method uses the Hugging Face pipeline for efficient and robust text classification. It's suitable for various classification tasks such as sentiment analysis, topic classification, and intent recognition.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and the classification results.
Example CURL Request for text classification:
/usr/bin/curl -X POST localhost:3000/api/v1/classification_pipeline -H \"Content-Type: application/json\" -d '{\"text\": \"The movie was fantastic, with great acting and plot.\"}' | jq\n
Accepts text input and returns classification results. The method uses the model and tokenizer to classify the text and provide the likelihood of each class label.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and the classification scores for each label.
Example CURL Request for text classification:
/usr/bin/curl -X POST localhost:3000/api/v1/classify -H \"Content-Type: application/json\" -d '{\n \"text\": \"tata sons lost a major contract to its rival mahindra motors\"\n }' | jq\n
InstructionAPI is designed for generating text based on prompts using instruction-tuned language models. It serves as an interface to Hugging Face's pre-trained instruction-tuned models, providing a flexible API for various text generation tasks. It can be used in scenarios ranging from generating creative content to providing instructions or answers based on the prompts.
Attributes:
Name Type Description modelAny
The loaded instruction-tuned language model.
tokenizerAny
The tokenizer for processing text suitable for the model.
Methods
complete(**kwargs: Any) -> Dict[str, Any]: Generates text based on the given prompt and decoding strategy.
listen(**model_args: Any) -> None: Starts a server to listen for text generation requests.
Handles chat interaction using the Hugging Face pipeline. This method enables conversational text generation, simulating a chat-like interaction based on user and system prompts.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments containing 'user_prompt' and 'system_prompt'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the user prompt, system prompt, and chat interaction results.
Example CURL Request for chat interaction:
/usr/bin/curl -X POST localhost:3001/api/v1/chat -H \"Content-Type: application/json\" -d '{\n \"user_prompt\": \"What is the capital of France?\",\n \"system_prompt\": \"The capital of France is\"\n }' | jq\n
Handles POST requests to generate chat completions using the llama.cpp engine. This method accepts various parameters for customizing the chat completion request, including messages, sampling settings, and more.
Parameters:
Name Type Description Default messagesList[Dict[str, str]]
The chat messages for generating a response.
required functionsOptional[List[Dict]]
A list of functions to use for the chat completion (advanced usage).
required function_callOptional[Dict]
A function call to use for the chat completion (advanced usage).
required toolsOptional[List[Dict]]
A list of tools to use for the chat completion (advanced usage).
required tool_choiceOptional[Dict]
A tool choice option for the chat completion (advanced usage).
required temperaturefloat
The temperature to use for sampling, controlling randomness.
required top_pfloat
The nucleus sampling's top-p parameter, controlling diversity.
required top_kint
The top-k sampling parameter, limiting the token selection pool.
required min_pfloat
The minimum probability threshold for sampling.
required typical_pfloat
The typical-p parameter for locally typical sampling.
required streambool
Flag to stream the results.
required stopOptional[Union[str, List[str]]]
Tokens or sequences where generation should stop.
required seedOptional[int]
Seed for random number generation to ensure reproducibility.
required response_formatOptional[Dict]
Specifies the format of the generated response.
required max_tokensOptional[int]
Maximum number of tokens to generate.
required presence_penaltyfloat
Penalty for token presence to discourage repetition.
required frequency_penaltyfloat
Penalty for token frequency to discourage common tokens.
required repeat_penaltyfloat
Penalty applied to tokens that are repeated.
required tfs_zfloat
Tail-free sampling parameter to adjust the likelihood of tail tokens.
required mirostat_modeint
Mirostat sampling mode for dynamic adjustments.
required mirostat_taufloat
Tau parameter for mirostat sampling, controlling deviation.
required mirostat_etafloat
Eta parameter for mirostat sampling, controlling adjustment speed.
required modelOptional[str]
Specifies the model to use for generation.
required logits_processorOptional[List]
List of logits processors for advanced generation control.
required grammarOptional[Dict]
Specifies grammar rules for the generated text.
required logit_biasOptional[Dict[str, float]]
Adjustments to the logits of specified tokens.
required logprobsOptional[bool]
Whether to include log probabilities in the output.
required top_logprobsOptional[int]
Number of top log probabilities to include.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the chat completion response or an error message.
Example CURL Request:
curl -X POST \"http://localhost:3000/api/v1/chat_llama_cpp\" -H \"Content-Type: application/json\" -d '{\n \"messages\": [\n {\"role\": \"user\", \"content\": \"What is the capital of France?\"},\n {\"role\": \"system\", \"content\": \"The capital of France is\"}\n ],\n \"temperature\": 0.2,\n \"top_p\": 0.95,\n \"top_k\": 40,\n \"max_tokens\": 50,\n }'\n
Handles POST requests to generate chat completions using the VLLM (Versatile Language Learning Model) engine. This method accepts various parameters for customizing the chat completion request, including message content, generation settings, and more.
Parameters:
Name Type Description Default messagesList[Dict[str, str]]
The chat messages for generating a response. Each message should include a 'role' (either 'user' or 'system') and 'content'.
required temperaturefloat
The sampling temperature. Defaults to 0.7. Higher values generate more random completions.
required top_pfloat
The nucleus sampling probability. Defaults to 1.0. A smaller value leads to higher diversity.
required nint
The number of completions to generate. Defaults to 1.
required max_tokensint
The maximum number of tokens to generate. Controls the length of the generated response.
required stopUnion[str, List[str]]
Sequence(s) where the generation should stop. Can be a single string or a list of strings.
required streambool
Whether to stream the response. Streaming may be useful for long completions.
required presence_penaltyfloat
Adjusts the likelihood of tokens based on their presence in the conversation so far. Defaults to 0.0.
required frequency_penaltyfloat
Adjusts the likelihood of tokens based on their frequency in the conversation so far. Defaults to 0.0.
required logit_biasDict[str, float]
Adjustments to the logits of specified tokens, identified by token IDs as keys and adjustment values as values.
required userstr
An identifier for the user making the request. Can be used for logging or customization.
required best_ofint
Generates 'n' completions server-side and returns the best one. Higher values incur more computation cost.
required top_kint
Filters the generated tokens to the top-k tokens with the highest probabilities. Defaults to -1, which disables top-k filtering.
required ignore_eosbool
Whether to ignore the end-of-sentence token in generation. Useful for more fluid continuations.
required use_beam_searchbool
Whether to use beam search instead of sampling for generation. Beam search can produce more coherent results.
required stop_token_idsList[int]
List of token IDs that should cause generation to stop.
required skip_special_tokensbool
Whether to skip special tokens (like padding or end-of-sequence tokens) in the output.
required spaces_between_special_tokensbool
Whether to insert spaces between special tokens in the output.
required add_generation_promptbool
Whether to prepend the generation prompt to the output.
required echobool
Whether to include the input prompt in the output.
required repetition_penaltyfloat
Penalty applied to tokens that have been generated previously. Defaults to 1.0, which applies no penalty.
required min_pfloat
Sets a minimum threshold for token probabilities. Tokens with probabilities below this threshold are filtered out.
required include_stop_str_in_outputbool
Whether to include the stop string(s) in the output.
required length_penaltyfloat
Exponential penalty to the length for beam search. Only relevant if use_beam_search is True.
required
Dict[str, Any]: A dictionary with the chat completion response or an error message.
Example CURL Request:
curl -X POST \"http://localhost:3000/api/v1/chat_vllm\" -H \"Content-Type: application/json\" -d '{\n \"messages\": [\n {\"role\": \"user\", \"content\": \"Whats the weather like in London?\"}\n ],\n \"temperature\": 0.7,\n \"top_p\": 1.0,\n \"n\": 1,\n \"max_tokens\": 50,\n \"stream\": false,\n \"presence_penalty\": 0.0,\n \"frequency_penalty\": 0.0,\n \"logit_bias\": {},\n \"user\": \"example_user\"\n }'\n
This request asks the VLLM engine to generate a completion for the provided chat context, with specified generation settings."},{"location":"text/api/instruction_tuning/#geniusrise_text.instruction.api.InstructionAPI.complete","title":"complete(**kwargs)","text":"
Handles POST requests to generate text based on the given prompt and decoding strategy. It uses the pre-trained\n model specified in the setup to generate a completion for the input prompt.\n\n Args:\n **kwargs (Any): Arbitrary keyword arguments containing the 'prompt' and other parameters for text generation.\n\n Returns:\n Dict[str, Any]: A dictionary containing the original prompt and the generated completion.\n\n Example CURL Requests:\n ```bash\n /usr/bin/curl -X POST localhost:3001/api/v1/complete -H \"Content-Type: application/json\" -d '{\n \"prompt\": \"<|system|>\n
<|end|> <|user|> How do I sort a list in Python?<|end|> <|assistant|>\", \"decoding_strategy\": \"generate\", \"max_new_tokens\": 100, \"do_sample\": true, \"temperature\": 0.7, \"top_k\": 50, \"top_p\": 0.95 }' | jq ```
LanguageModelAPI is a class for interacting with pre-trained language models to generate text. It allows for customizable text generation via a CherryPy web server, handling requests and generating responses using a specified language model. This class is part of the GeniusRise ecosystem for facilitating NLP tasks.
Attributes:
Name Type Description modelAny
The loaded language model used for text generation.
tokenizerAny
The tokenizer corresponding to the language model, used for processing input text.
Methods
complete(**kwargs: Any) -> Dict[str, Any]: Generates text based on provided prompts and model parameters.
Handles POST requests to generate text based on a given prompt and model-specific parameters. This method is exposed as a web endpoint through CherryPy and returns a JSON response containing the original prompt, the generated text, and any additional returned information from the model.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments containing the prompt, and any additional parameters
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary with the original prompt, generated text, and other model-specific information.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/complete \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"prompt\": \"Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n### Instruction:\\nWrite a PRD for Oauth auth using keycloak\\n\\n### Response:\",\n \"decoding_strategy\": \"generate\",\n \"max_new_tokens\": 1024,\n \"do_sample\": true\n }' | jq\n
Handles POST requests to generate chat completions using the llama.cpp engine. This method accepts various parameters for customizing the chat completion request, including messages, sampling settings, and more.
Parameters:
Name Type Description Default prompt
The prompt to generate text from.
required suffix
A suffix to append to the generated text. If None, no suffix is appended.
required max_tokens
The maximum number of tokens to generate. If max_tokens <= 0 or None, the maximum number of tokens to generate is unlimited and depends on n_ctx.
required temperature
The temperature to use for sampling.
required top_p
The top-p value to use for nucleus sampling. Nucleus sampling described in academic paper \"The Curious Case of Neural Text Degeneration\" https://arxiv.org/abs/1904.09751
required min_p
The min-p value to use for minimum p sampling. Minimum P sampling as described in https://github.com/ggerganov/llama.cpp/pull/3841
required typical_p
The typical-p value to use for sampling. Locally Typical Sampling implementation described in the paper https://arxiv.org/abs/2202.00666.
required logprobs
The number of logprobs to return. If None, no logprobs are returned.
required echo
Whether to echo the prompt.
required stop
A list of strings to stop generation when encountered.
required frequency_penalty
The penalty to apply to tokens based on their frequency in the prompt.
required presence_penalty
The penalty to apply to tokens based on their presence in the prompt.
required repeat_penalty
The penalty to apply to repeated tokens.
required top_k
The top-k value to use for sampling. Top-K sampling described in academic paper \"The Curious Case of Neural Text Degeneration\" https://arxiv.org/abs/1904.09751
required stream
Whether to stream the results.
required seed
The seed to use for sampling.
required tfs_z
The tail-free sampling parameter. Tail Free Sampling described in https://www.trentonbricken.com/Tail-Free-Sampling/.
required mirostat_mode
The mirostat sampling mode.
required mirostat_tau
The target cross-entropy (or surprise) value you want to achieve for the generated text. A higher value corresponds to more surprising or less predictable text, while a lower value corresponds to less surprising or more predictable text.
required mirostat_eta
The learning rate used to update mu based on the error between the target and observed surprisal of the sampled word. A larger learning rate will cause mu to be updated more quickly, while a smaller learning rate will result in slower updates.
required model
The name to use for the model in the completion object.
required stopping_criteria
A list of stopping criteria to use.
required logits_processor
A list of logits processors to use.
required grammar
A grammar to use for constrained sampling.
required logit_bias
A logit bias to use.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the chat completion response or an error message.
Example CURL Request:
curl -X POST \"http://localhost:3001/api/v1/complete_llama_cpp\" -H \"Content-Type: application/json\" -d '{\n \"prompt\": \"Whats the weather like in London?\",\n \"temperature\": 0.7,\n \"top_p\": 0.95,\n \"top_k\": 40,\n \"max_tokens\": 50,\n \"repeat_penalty\": 1.1\n }'\n
Handles POST requests to generate chat completions using the VLLM (Versatile Language Learning Model) engine. This method accepts various parameters for customizing the chat completion request, including message content, generation settings, and more.
**kwargs (Any): Arbitrary keyword arguments. Expects data in JSON format containing any of the following keys:
messages (Union[str, List[Dict[str, str]]]): The messages for the chat context.
temperature (float, optional): The sampling temperature. Defaults to 0.7.
top_p (float, optional): The nucleus sampling probability. Defaults to 1.0.
n (int, optional): The number of completions to generate. Defaults to 1.
max_tokens (int, optional): The maximum number of tokens to generate.
stop (Union[str, List[str]], optional): Stop sequence to end generation.
stream (bool, optional): Whether to stream the response. Defaults to False.
presence_penalty (float, optional): The presence penalty. Defaults to 0.0.
frequency_penalty (float, optional): The frequency penalty. Defaults to 0.0.
logit_bias (Dict[str, float], optional): Adjustments to the logits of specified tokens.
user (str, optional): An identifier for the user making the request.
(Additional model-specific parameters)
Dict[str, Any]: A dictionary with the chat completion response or an error message.
Example CURL Request:
curl -v -X POST \"http://localhost:3000/api/v1/complete_vllm\" -H \"Content-Type: application/json\" -u \"user:password\" -d '{\n \"messages\": [\"Whats the weather like in London?\"],\n \"temperature\": 0.7,\n \"top_p\": 1.0,\n \"n\": 1,\n \"max_tokens\": 50,\n \"stream\": false,\n \"presence_penalty\": 0.0,\n \"frequency_penalty\": 0.0,\n \"logit_bias\": {},\n \"user\": \"example_user\"\n }'\n
This request asks the VLLM engine to generate a completion for the provided chat context, with specified generation settings."},{"location":"text/api/ner/","title":"Named Entity Recognition","text":"
Bases: TextAPI
NamedEntityRecognitionAPI serves a Named Entity Recognition (NER) model using the Hugging Face transformers library. It is designed to recognize and classify named entities in text into predefined categories such as the names of persons, organizations, locations, expressions of times, quantities, monetary values, percentages, etc.
Attributes:
Name Type Description modelAny
The loaded NER model, typically a Hugging Face transformer model specialized for token classification.
tokenizerAny
The tokenizer for preprocessing text compatible with the loaded model.
Recognizes named entities in the input text using the Hugging Face pipeline.
This method leverages a pre-trained NER model to identify and classify entities in text into categories such as names, organizations, locations, etc. It's suitable for processing various types of text content.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and a list of recognized entities.
Example CURL Request for NER:
curl -X POST localhost:3000/api/v1/ner_pipeline -H \"Content-Type: application/json\" -d '{\"text\": \"John Doe works at OpenAI in San Francisco.\"}' | jq\n
Endpoint for recognizing named entities in the input text using the loaded NER model.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and a list of recognized entities with their respective types.
Example CURL Requests:
curl -X POST localhost:3000/api/v1/recognize_entities \\\n-H \"Content-Type: application/json\" \\\n-d '{\"text\": \"John Doe works at OpenAI in San Francisco.\"}' | jq\n
curl -X POST localhost:3000/api/v1/recognize_entities \\\n-H \"Content-Type: application/json\" \\\n-d '{\"text\": \"Alice is going to visit the Eiffel Tower in Paris next summer.\"}' | jq\n
"},{"location":"text/api/nli/","title":"Natural Language Inference","text":"
Bases: TextAPI
Represents a Natural Language Inference (NLI) API leveraging Hugging Face's transformer models. This class is capable of handling various NLI tasks such as entailment, classification, similarity checking, and more. Utilizes CherryPy for exposing API endpoints that can be interacted with via standard HTTP requests.
Attributes:
Name Type Description modelAutoModelForSequenceClassification
The loaded Hugging Face model for sequence classification tasks.
tokenizerAutoTokenizer
The tokenizer corresponding to the model, used for processing input text.
CLI Usage Example: For interacting with the NLI API, you would typically start the server using a command similar to one listed in the provided examples. After the server is running, you can use CURL commands to interact with the different endpoints.
Endpoint for classifying the input text into one of the provided candidate labels using zero-shot classification.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' and 'candidate_labels'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the input text, candidate labels, and classification scores.
Example CURL Request:
curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text\": \"The new movie is a thrilling adventure in space\",\n \"candidate_labels\": [\"entertainment\", \"politics\", \"business\"]\n }'\n
Detects the intent of the input text from a list of possible intents.
Parameters:
Name Type Description Default textstr
The input text.
required intentsList[str]
A list of possible intents.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the input text and detected intent with its score.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/detect_intent \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"intents\": [\"teach\",\"sell\",\"note\",\"advertise\",\"promote\"]\n }' | jq\n
Endpoint for evaluating the entailment relationship between a premise and a hypothesis. It returns the relationship scores across possible labels like entailment, contradiction, and neutral.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'premise' and 'hypothesis'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the premise, hypothesis, and their relationship scores.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/entailment \\\n-H \"Content-Type: application/json\" \\\\\\\n-d '{\n \"premise\": \"This a very good entry level smartphone, battery last 2-3 days after fully charged when connected to the internet. No memory lag issue when playing simple hidden object games. Performance is beyond my expectation, i bought it with a good bargain, couldnt ask for more!\",\n \"hypothesis\": \"the phone has an awesome battery life\"\n }' | jq\n
Performs fact checking on a statement given a context.
Parameters:
Name Type Description Default contextstr
The context or background information.
required statementstr
The statement to fact check.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing fact checking scores.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/fact_checking \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"context\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"statement\": \"The author is looking for a home loan\"\n }' | jq\n
Performs question answering for multiple choice questions.
Parameters:
Name Type Description Default questionstr
The question text.
required choicesList[str]
A list of possible answers.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the scores for each answer choice.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/question_answering \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"question\": \"[ML-1T-2] is the dimensional formula of\",\n \"choices\": [\"force\", \"coefficient of friction\", \"modulus of elasticity\", \"energy\"]\n }' | jq\n
Evaluates the textual similarity between two texts.
Parameters:
Name Type Description Default text1str
The first text.
required text2str
The second text.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing similarity score.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/textual_similarity \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text1\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"text2\": \"There is something magical about training neural networks. Their simplicity coupled with their power is astonishing.\"\n }' | jq\n
Performs zero-shot classification using the Hugging Face pipeline. It allows classification of text without explicitly provided labels.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'premise' and 'hypothesis'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the premise, hypothesis, and their classification scores.
Example CURL Request for zero-shot classification:
curl -X POST localhost:3000/api/v1/zero_shot_classification -H \"Content-Type: application/json\" -d '{\n \"premise\": \"A new study shows that the Mediterranean diet is good for heart health.\",\n \"hypothesis\": \"The study is related to diet and health.\"\n }' | jq\n
A class for handling different types of QA models, including traditional QA, TAPAS (Table-based QA), and TAPEX. It utilizes the Hugging Face transformers library to provide state-of-the-art question answering capabilities across various formats of data including plain text and tabular data.
Attributes:
Name Type Description modelAutoModelForQuestionAnswering | AutoModelForTableQuestionAnswering
The pre-trained QA model (traditional, TAPAS, or TAPEX).
tokenizerAutoTokenizer
The tokenizer used to preprocess input text.
Methods
answer(self, **kwargs: Any) -> Dict[str, Any]: Answers questions based on the provided context (text or table).
Answers questions based on the provided context (text or table). It adapts to the model type (traditional, TAPAS, TAPEX) and provides answers accordingly.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing the 'question' and 'data' (context or table).
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the question, context/table, and answer(s).
Example CURL Request for Text-based QA:
curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-d '{\"question\": \"What is the capital of France?\", \"data\": \"France is a country in Europe. Its capital is Paris.\"}'\n
Example CURL Requests:
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"question\": \"What is the common wisdom about RNNs?\"\n }' | jq\n
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"data\": [\n {\"Name\": \"Alice\", \"Age\": \"30\"},\n {\"Name\": \"Bob\", \"Age\": \"25\"}\n ],\n \"question\": \"what is their total age?\"\n}\n' | jq\n
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"data\": {\"Actors\": [\"Brad Pitt\", \"Leonardo Di Caprio\", \"George Clooney\"], \"Number of movies\": [\"87\", \"53\", \"69\"]},\n \"question\": \"how many movies does Leonardo Di Caprio have?\"\n}\n' | jq\n
Answers questions using the Hugging Face pipeline based on the provided context.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'question' and 'data'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the question, context, and the answer.
Example CURL Request for QA:
curl -X POST localhost:3000/api/v1/answer_pipeline -H \"Content-Type: application/json\" -d '{\"question\": \"Who is the CEO of Tesla?\", \"data\": \"Elon Musk is the CEO of Tesla.\"}'\n
A class for serving a Hugging Face-based summarization model. This API provides an interface to submit text and receive a summarized version, utilizing state-of-the-art machine learning models for text summarization.
Attributes:
Name Type Description modelAutoModelForSeq2SeqLM
The loaded Hugging Face model for summarization.
tokenizerAutoTokenizer
The tokenizer for preprocessing text.
Methods
summarize(self, **kwargs: Any) -> Dict[str, Any]: Summarizes the input text based on the given parameters.
Summarizes the input text based on the given parameters using a machine learning model. The method accepts parameters via a POST request and returns the summarized text.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments. Expected to receive these from the POST request's JSON body.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the input text and its summary.
Example CURL Requests:
/usr/bin/curl -X POST localhost:3000/api/v1/summarize \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"decoding_strategy\": \"generate\",\n \"bos_token_id\": 0,\n \"decoder_start_token_id\": 2,\n \"early_stopping\": true,\n \"eos_token_id\": 2,\n \"forced_bos_token_id\": 0,\n \"forced_eos_token_id\": 2,\n \"length_penalty\": 2.0,\n \"max_length\": 142,\n \"min_length\": 56,\n \"no_repeat_ngram_size\": 3,\n \"num_beams\": 4,\n \"pad_token_id\": 1,\n \"do_sample\": false\n }' | jq\n
/usr/bin/curl -X POST localhost:3000/api/v1/summarize \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"decoding_strategy\": \"generate\",\n \"early_stopping\": true,\n \"length_penalty\": 2.0,\n \"max_length\": 142,\n \"min_length\": 56,\n \"no_repeat_ngram_size\": 3,\n \"num_beams\": 4\n }' | jq\n
Summarizes the input text using the Hugging Face pipeline based on given parameters.
Parameters:
Name Type Description Default **kwargsAny
Keyword arguments containing parameters for summarization.
{}
Returns:
Type Description Dict[str, Any]
A dictionary containing the input text and its summary.
Example CURL Request for summarization: curl -X POST localhost:3000/api/v1/summarize_pipeline -H \"Content-Type: application/json\" -d '{\"text\": \"Your long text here\"}'
A class for serving a Hugging Face-based translation model as a web API. This API allows users to submit text for translation and receive translated text in the specified target language using advanced machine learning models.
Parameters:
Name Type Description Default inputBatchInput
Configurations and data inputs for the batch process.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the translation task.
required **kwargsAny
Additional keyword arguments for extended configurations.
Translates text to a specified target language using the underlying Hugging Face model.
This endpoint accepts JSON data with the text and language details, processes it through the machine learning model, and returns the translated text.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, usually empty as parameters are in the POST body.
{} POST body parameters
text (str): The text to be translated. decoding_strategy (str): Strategy to use for decoding text; e.g., 'beam_search', 'greedy'. Default is 'generate'. source_lang (str): Source language code. target_lang (str): Target language code. Default is 'en'. additional_params (dict): Other model-specific parameters for translation.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary with the original text, target language, and translated text.
Endpoint for translating text using a pre-initialized Hugging Face translation pipeline. This method is designed to handle translation requests more efficiently by utilizing a preloaded model and tokenizer, reducing the overhead of loading these components for each request.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original text, source language, target language, and the translated text.
"},{"location":"text/bulk/base/","title":"Base Fine Tuner","text":"
Bases: Bolt
TextBulk is a foundational class for enabling bulk processing of text with various generation models. It primarily focuses on using Hugging Face models to provide a robust and efficient framework for large-scale text generation tasks. The class supports various decoding strategies to generate text that can be tailored to specific needs or preferences.
Attributes:
Name Type Description modelAutoModelForCausalLM
The language model for text generation.
tokenizerAutoTokenizer
The tokenizer for preparing input data for the model.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for the batch process.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the Bolt.
required **kwargs
Arbitrary keyword arguments for extended configurations.
{} Methods
text(**kwargs: Any) -> Dict[str, Any]: Provides an API endpoint for text generation functionality. Accepts various parameters for customizing the text generation process.
generate(prompt: str, decoding_strategy: str = \"generate\", **generation_params: Any) -> dict: Generates text based on the provided prompt and parameters. Supports multiple decoding strategies for diverse applications.
The class serves as a versatile tool for text generation, supporting various models and configurations. It can be extended or used as is for efficient text generation tasks.
TextClassificationBulk is designed to handle bulk text classification tasks using Hugging Face models efficiently and effectively. It allows for processing large datasets, utilizing state-of-the-art machine learning models to provide accurate classification of text data into predefined labels.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for the batch process.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the classification task.
required **kwargs
Arbitrary keyword arguments for extended configurations.
Perform bulk classification using the specified model and tokenizer. This method handles the entire classification process including loading the model, processing input data, predicting classifications, and saving the results.
Parameters:
Name Type Description Default model_namestr
Name or path of the model.
required model_classstr
Class name of the model (default \"AutoModelForSequenceClassification\").
The maximum length for tokenization. Defaults to 512.
512
Returns:
Name Type Description DatasetOptional[Dataset]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/bulk/classification/#geniusrise_text.classification.bulk.TextClassificationBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/classification/#geniusrise_text.classification.bulk.TextClassificationBulk.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
InstructionBulk is a class designed to perform bulk text generation tasks using Hugging Face's instruction-tuned language models. It is optimized for large-scale text generation, providing an efficient interface to use state-of-the-art machine learning models for generating text based on a set of instructions or prompts.
Attributes:
Name Type Description modelAny
The loaded, pre-trained instruction-tuned language model.
tokenizerAny
The tokenizer for processing text compatible with the model.
Methods
load_dataset(dataset_path: str, max_length: int = 1024, **kwargs) -> Optional[Dataset]: Loads a dataset for text generation tasks from the specified directory.
perform(model_name: str, **kwargs: Any) -> None: Performs bulk text generation using the specified model and tokenizer.
Loads a dataset from the specified path. This method supports various data formats including JSON, CSV, Parquet, and others. It's designed to facilitate the bulk processing of text data for generation tasks.
Parameters:
Name Type Description Default dataset_pathstr
Path to the directory containing the dataset files.
required max_lengthint
Maximum token length for text processing (default is 1024).
1024**kwargs
Additional keyword arguments for dataset loading.
{}
Returns:
Type Description Optional[Dataset]
Optional[Dataset]: A Dataset object if loading is successful; otherwise, None.
Raises:
Type Description Exception
If an error occurs during dataset loading.
"},{"location":"text/bulk/instruction_tuning/#geniusrise_text.instruction.bulk.InstructionBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/instruction_tuning/#geniusrise_text.instruction.bulk.InstructionBulk.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
Performs text generation in bulk using a specified instruction-tuned model. This method handles the entire process, including model loading, prompt processing, text generation, and saving the results.
Parameters:
Name Type Description Default model_namestr
The name or path of the instruction-tuned model.
required model_classstr
The class of the language model. Defaults to \"AutoModelForCausalLM\".
'AutoModelForCausalLM'tokenizer_classstr
The class of the tokenizer. Defaults to \"AutoTokenizer\".
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference. Defaults to False.
Falseprecisionstr
Precision for model computation. Defaults to \"float16\".
'float16'quantizationint
Level of quantization for optimizing model size and speed. Defaults to 0.
0device_mapstr | Dict | None
Specific device to use for computation. Defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for devices. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization. Defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization. Defaults to False.
Falsedecoding_strategystr
Strategy for decoding the completion. Defaults to \"generate\".
'generate'**kwargsAny
Configuration and additional arguments for text generation such as model class, tokenizer class, precision, device map, and other generation-related parameters.
{} Note
Additional arguments are passed directly to the model and tokenizer initialization and the generation method.
Performs bulk text generation using the LLaMA model with llama.cpp backend. This method handles the entire process, including model loading, prompt processing, text generation, and saving the results.
Parameters:
Name Type Description Default modelstr
Path or identifier for the LLaMA model.
required filenameOptional[str]
Optional filename or glob pattern to match the model file.
Performs bulk text generation using the Versatile Language Learning Model (VLLM) with specified parameters for fine-tuning model behavior, including quantization and parallel processing settings. This method is designed to process large datasets efficiently by leveraging VLLM capabilities for generating high-quality text completions based on provided prompts.
Parameters:
Name Type Description Default model_namestr
The name or path of the VLLM model to use for text generation.
required use_cudabool
Flag indicating whether to use CUDA for GPU acceleration.
Falseprecisionstr
Precision of computations, can be \"float16\", \"bfloat16\", etc.
'float16'quantizationint
Level of quantization for model weights, 0 for none.
0device_mapstr | Dict | None
Specific device(s) to use for model inference.
'auto'vllm_tokenizer_modestr
Mode of the tokenizer (\"auto\", \"fast\", or \"slow\").
'auto'vllm_download_dirOptional[str]
Directory to download and load the model and tokenizer.
Nonevllm_load_formatstr
Format to load the model, e.g., \"auto\", \"pt\".
'auto'vllm_seedint
Seed for random number generation.
42vllm_max_model_lenint
Maximum sequence length the model can handle.
1024vllm_enforce_eagerbool
Enforce eager execution instead of using optimization techniques.
Disable custom all-reduce kernel and fall back to NCCL.
Falsevllm_max_num_batched_tokensOptional[int]
Maximum number of tokens to be processed in a single iteration.
Nonevllm_max_num_seqsint
Maximum number of sequences to be processed in a single iteration.
64vllm_max_paddingsint
Maximum number of paddings to be added to a batch.
512vllm_max_lora_rankOptional[int]
Maximum rank for LoRA adjustments.
Nonevllm_max_lorasOptional[int]
Maximum number of LoRA adjustments.
Nonevllm_max_cpu_lorasOptional[int]
Maximum number of LoRA adjustments stored on CPU.
Nonevllm_lora_extra_vocab_sizeint
Additional vocabulary size for LoRA.
0vllm_placement_groupOptional[dict]
Ray placement group for distributed execution.
Nonevllm_log_statsbool
Whether to log statistics during model operation.
Falsenotification_emailOptional[str]
Email to send notifications upon completion.
Nonebatch_sizeint
Number of prompts to process in each batch for efficient memory usage.
32**kwargsAny
Additional keyword arguments for generation settings like temperature, top_p, etc.
{}
This method automates the loading of large datasets, generation of text completions, and saving results, facilitating efficient and scalable text generation tasks.
LanguageModelBulk is designed for large-scale text generation using Hugging Face language models in a bulk processing manner. It's particularly useful for tasks such as bulk content creation, summarization, or any other scenario where large datasets need to be processed with a language model.
Attributes:
Name Type Description modelAny
The loaded language model used for text generation.
tokenizerAny
The tokenizer corresponding to the language model, used for processing input text.
Parameters:
Name Type Description Default inputBatchInput
Configuration for the input data.
required outputBatchOutput
Configuration for the output data.
required stateState
State management for the API.
required **kwargsAny
Arbitrary keyword arguments for extended functionality.
Performs text completion on the loaded dataset using the specified model and tokenizer. The method handles the entire process, including model loading, text generation, and saving the results.
Parameters:
Name Type Description Default model_namestr
The name of the language model to use for text completion.
required model_classstr
The class of the language model. Defaults to \"AutoModelForCausalLM\".
'AutoModelForCausalLM'tokenizer_classstr
The class of the tokenizer. Defaults to \"AutoTokenizer\".
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference. Defaults to False.
Falseprecisionstr
Precision for model computation. Defaults to \"float16\".
'float16'quantizationint
Level of quantization for optimizing model size and speed. Defaults to 0.
0device_mapstr | Dict | None
Specific device to use for computation. Defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for devices. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization. Defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization. Defaults to False.
Falsedecoding_strategystr
Strategy for decoding the completion. Defaults to \"generate\".
Performs bulk text generation using the LLaMA model with llama.cpp backend. This method handles the entire process, including model loading, prompt processing, text generation, and saving the results.
Parameters:
Name Type Description Default modelstr
Path or identifier for the LLaMA model.
required filenameOptional[str]
Optional filename or glob pattern to match the model file.
Performs bulk text generation using the Versatile Language Learning Model (VLLM) with specified parameters for fine-tuning model behavior, including quantization and parallel processing settings. This method is designed to process large datasets efficiently by leveraging VLLM capabilities for generating high-quality text completions based on provided prompts.
Parameters:
Name Type Description Default model_namestr
The name or path of the VLLM model to use for text generation.
required use_cudabool
Flag indicating whether to use CUDA for GPU acceleration.
Falseprecisionstr
Precision of computations, can be \"float16\", \"bfloat16\", etc.
'float16'quantizationint
Level of quantization for model weights, 0 for none.
0device_mapstr | Dict | None
Specific device(s) to use for model inference.
'auto'vllm_tokenizer_modestr
Mode of the tokenizer (\"auto\", \"fast\", or \"slow\").
'auto'vllm_download_dirOptional[str]
Directory to download and load the model and tokenizer.
Nonevllm_load_formatstr
Format to load the model, e.g., \"auto\", \"pt\".
'auto'vllm_seedint
Seed for random number generation.
42vllm_max_model_lenint
Maximum sequence length the model can handle.
1024vllm_enforce_eagerbool
Enforce eager execution instead of using optimization techniques.
Disable custom all-reduce kernel and fall back to NCCL.
Falsevllm_max_num_batched_tokensOptional[int]
Maximum number of tokens to be processed in a single iteration.
Nonevllm_max_num_seqsint
Maximum number of sequences to be processed in a single iteration.
64vllm_max_paddingsint
Maximum number of paddings to be added to a batch.
512vllm_max_lora_rankOptional[int]
Maximum rank for LoRA adjustments.
Nonevllm_max_lorasOptional[int]
Maximum number of LoRA adjustments.
Nonevllm_max_cpu_lorasOptional[int]
Maximum number of LoRA adjustments stored on CPU.
Nonevllm_lora_extra_vocab_sizeint
Additional vocabulary size for LoRA.
0vllm_placement_groupOptional[dict]
Ray placement group for distributed execution.
Nonevllm_log_statsbool
Whether to log statistics during model operation.
Falsenotification_emailOptional[str]
Email to send notifications upon completion.
Nonebatch_sizeint
Number of prompts to process in each batch for efficient memory usage.
32**kwargsAny
Additional keyword arguments for generation settings like temperature, top_p, etc.
{}
This method automates the loading of large datasets, generation of text completions, and saving results, facilitating efficient and scalable text generation tasks.
The maximum length for tokenization. Defaults to 512.
512**kwargs
Additional keyword arguments to pass to the underlying dataset loading functions.
{}
Returns:
Name Type Description DatasetOptional[Dataset]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/bulk/language_model/#geniusrise_text.language_model.bulk.LanguageModelBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/language_model/#geniusrise_text.language_model.bulk.LanguageModelBulk.load_dataset--dataset-files-saved-by-hugging-face-datasets-library","title":"Dataset files saved by Hugging Face datasets library","text":"
The directory should contain 'dataset_info.json' and other related files.
NamedEntityRecognitionBulk is a class designed for bulk processing of Named Entity Recognition (NER) tasks. It leverages state-of-the-art NER models from Hugging Face's transformers library to identify and classify entities such as person names, locations, organizations, and other types of entities from a large corpus of text.
This class provides functionalities to load large datasets, configure NER models, and perform entity recognition in bulk, making it suitable for processing large volumes of text data efficiently.
Attributes:
Name Type Description modelAny
The NER model loaded for entity recognition tasks.
tokenizerAny
The tokenizer used for text pre-processing in alignment with the model.
Initializes the NamedEntityRecognitionBulk class with specified input, output, and state configurations. Sets up the NER model and tokenizer for bulk entity recognition tasks.
Parameters:
Name Type Description Default inputBatchInput
The input data configuration.
required outputBatchOutput
The output data configuration.
required stateState
The state management for the API.
required **kwargsAny
Additional keyword arguments for extended functionality.
Loads a dataset from the specified directory path. The method supports various data formats and structures, ensuring that the dataset is properly formatted for NER tasks.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required **kwargsAny
Additional keyword arguments to handle specific dataset loading scenarios.
{}
Returns:
Type Description Optional[Dataset]
Optional[Dataset]: The loaded dataset or None if an error occurs during loading.
"},{"location":"text/bulk/ner/#geniusrise_text.ner.bulk.NamedEntityRecognitionBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/ner/#geniusrise_text.ner.bulk.NamedEntityRecognitionBulk.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Performs bulk named entity recognition on the loaded dataset. The method processes the text in batches, applying the NER model to recognize entities.
Parameters:
Name Type Description Default model_namestr
The name or path of the NER model.
required max_lengthint
The maximum sequence length for the tokenizer.
512model_classstr
The class of the model, defaults to \"AutoModelForTokenClassification\".
'AutoModelForSeq2SeqLM'tokenizer_classstr
The class of the tokenizer, defaults to \"AutoTokenizer\".
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference, defaults to False.
Falseprecisionstr
Model computation precision, defaults to \"float16\".
'float16'quantizationint
Level of quantization for model size and speed optimization, defaults to 0.
0device_mapstr | Dict | None
Specific device configuration for computation, defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for the devices.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization, defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization, defaults to False.
Falsebatch_sizeint
Number of documents to process simultaneously, defaults to 32.
32**kwargsAny
Arbitrary keyword arguments for additional configuration.
{}
Returns:
Name Type Description NoneNone
The method processes the dataset and saves the predictions without returning any value.
"},{"location":"text/bulk/nli/","title":"Natural Language Inference","text":"
Bases: TextBulk
The NLIBulk class provides functionality for large-scale natural language inference (NLI) processing using Hugging Face transformers. It allows users to load datasets, configure models, and perform inference on batches of premise-hypothesis pairs.
Attributes:
Name Type Description inputBatchInput
Configuration and data inputs for the batch process.
Performs NLI inference on a loaded dataset using the specified model. The method processes the data in batches and saves the results to the configured output path.
Parameters:
Name Type Description Default model_namestr
Name or path of the NLI model.
required max_lengthint
Maximum length of the sequences for tokenization purposes. Defaults to 512.
512model_classstr
Class name of the model (e.g., \"AutoModelForSequenceClassification\"). Defaults to \"AutoModelForSeq2SeqLM\".
'AutoModelForSeq2SeqLM'tokenizer_classstr
Class name of the tokenizer (e.g., \"AutoTokenizer\"). Defaults to \"AutoTokenizer\".
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference. Defaults to False.
Falseprecisionstr
Precision for model computation (e.g., \"float16\"). Defaults to \"float16\".
'float16'quantizationint
Level of quantization for optimizing model size and speed. Defaults to 0.
0device_mapstr | Dict | None
Specific device to use for computation. Defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for devices. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization. Defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization. Defaults to False.
Falsebatch_sizeint
Number of premise-hypothesis pairs to process simultaneously. Defaults to 32.
32**kwargsAny
Arbitrary keyword arguments for model and generation configurations.
Load a commonsense reasoning dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory or file.
required max_lengthint
Maximum length of text sequences for tokenization purposes. Defaults to 512.
512**kwargs
Additional keyword arguments.
{}
Returns:
Name Type Description DatasetOptional[Dataset]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/bulk/nli/#geniusrise_text.nli.bulk.NLIBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/nli/#geniusrise_text.nli.bulk.NLIBulk.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
QABulk is a class designed for managing bulk question-answering tasks using Hugging Face models. It is capable of handling both traditional text-based QA and table-based QA (using TAPAS and TAPEX models), providing a versatile solution for automated question answering at scale.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for batch processing.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the bulk QA task.
required **kwargs
Arbitrary keyword arguments for extended functionality.
Perform bulk question-answering using the specified model and tokenizer. This method can handle various types of QA models including traditional, TAPAS, and TAPEX.
Parameters:
Name Type Description Default model_namestr
Name or path of the question-answering model.
required model_classstr
Class name of the model (e.g., \"AutoModelForQuestionAnswering\").
'AutoModelForQuestionAnswering'tokenizer_classstr
Class name of the tokenizer (e.g., \"AutoTokenizer\").
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference. Defaults to False.
Falseprecisionstr
Precision for model computation. Defaults to \"float16\".
'float16'quantizationint
Level of quantization for optimizing model size and speed. Defaults to 0.
0device_mapstr | Dict | None
Specific device to use for computation. Defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for devices. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization. Defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization. Defaults to False.
Falsebatch_sizeint
Number of questions to process simultaneously. Defaults to 32.
32**kwargsAny
Arbitrary keyword arguments for model and generation configurations.
{} Processing
The method processes the data in batches, utilizing the appropriate model based on the model name and generating answers for the questions provided in the dataset.
"},{"location":"text/bulk/question_answering/#geniusrise_text.qa.bulk.QABulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/question_answering/#geniusrise_text.qa.bulk.QABulk.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
SummarizationBulk is a class for managing bulk text summarization tasks using Hugging Face models. It is designed to handle large-scale summarization tasks efficiently and effectively, utilizing state-of-the-art machine learning models to provide high-quality summaries.
The class provides methods to load datasets, configure summarization models, and execute bulk summarization tasks.
"},{"location":"text/bulk/summarization/#geniusrise_text.summarization.bulk.SummarizationBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/summarization/#geniusrise_text.summarization.bulk.SummarizationBulk.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
Perform bulk summarization using the specified model and tokenizer. This method handles the entire summarization process including loading the model, processing input data, generating summarization, and saving the results.
Parameters:
Name Type Description Default model_namestr
Name or path of the translation model.
required originstr
Source language ISO code.
required targetstr
Target language ISO code.
required max_lengthint
Maximum length of the tokens (default 512).
512model_classstr
Class name of the model (default \"AutoModelForSeq2SeqLM\").
'AutoModelForSeq2SeqLM'tokenizer_classstr
Class name of the tokenizer (default \"AutoTokenizer\").
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference (default False).
Falseprecisionstr
Precision for model computation (default \"float16\").
'float16'quantizationint
Level of quantization for optimizing model size and speed (default 0).
0device_mapstr | Dict | None
Specific device to use for computation (default \"auto\").
'auto'max_memoryDict
Maximum memory configuration for devices.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization (default False).
Falseflash_attentionbool
Whether to use flash attention optimization (default False).
Falsebatch_sizeint
Number of translations to process simultaneously (default 32).
32max_lengthint
Maximum lenght of the summary to be generated (default 512).
512**kwargsAny
Arbitrary keyword arguments for model and generation configurations.
TranslationBulk is a class for managing bulk translations using Hugging Face models. It is designed to handle large-scale translation tasks efficiently and effectively, using state-of-the-art machine learning models to provide high-quality translations for various language pairs.
This class provides methods for loading datasets, configuring translation models, and executing bulk translation tasks.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for batch processing.
required outputBatchOutput
Configuration for output data handling.
required stateState
State management for translation tasks.
required **kwargs
Arbitrary keyword arguments for extended functionality.
"},{"location":"text/bulk/translation/#geniusrise_text.translation.bulk.TranslationBulk.load_dataset--supported-data-formats-and-structures-for-translation-tasks","title":"Supported Data Formats and Structures for Translation Tasks:","text":"
Note: All examples are assuming the source as \"en\", refer to the specific model for this parameter.
Perform bulk translation using the specified model and tokenizer. This method handles the entire translation process including loading the model, processing input data, generating translations, and saving the results.
Parameters:
Name Type Description Default model_namestr
Name or path of the translation model.
required originstr
Source language ISO code.
required targetstr
Target language ISO code.
required max_lengthint
Maximum length of the tokens (default 512).
512model_classstr
Class name of the model (default \"AutoModelForSeq2SeqLM\").
'AutoModelForSeq2SeqLM'tokenizer_classstr
Class name of the tokenizer (default \"AutoTokenizer\").
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference (default False).
Falseprecisionstr
Precision for model computation (default \"float16\").
'float16'quantizationint
Level of quantization for optimizing model size and speed (default 0).
0device_mapstr | Dict | None
Specific device to use for computation (default \"auto\").
'auto'max_memoryDict
Maximum memory configuration for devices.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization (default False).
Falseflash_attentionbool
Whether to use flash attention optimization (default False).
Falsebatch_sizeint
Number of translations to process simultaneously (default 32).
32**kwargsAny
Arbitrary keyword arguments for model and generation configurations.
{}"},{"location":"text/fine_tune/base/","title":"Base Fine Tuner","text":"
Bases: Bolt
A bolt for fine-tuning Hugging Face models.
This bolt uses the Hugging Face Transformers library to fine-tune a pre-trained model. It uses the Trainer class from the Transformers library to handle the training.
A bolt for fine-tuning Hugging Face models for text classification tasks.
This class extends the TextFineTuner and specializes in fine-tuning models for text classification. It provides additional functionalities for loading and preprocessing text classification datasets in various formats.
The maximum length for tokenization. Defaults to 512.
512
Returns:
Name Type Description DatasetOptional[Dataset]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/classification/#geniusrise_text.classification.fine_tune.TextClassificationFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/classification/#geniusrise_text.classification.fine_tune.TextClassificationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"label\": \"The label\"}\n
A bolt for fine-tuning Hugging Face models on instruction tuning tasks.
This class inherits from TextFineTuner and specializes in fine-tuning models for instruction-based tasks. It provides additional methods for loading and preparing datasets in various formats, as well as computing custom metrics.
Compute evaluation metrics for the model's predictions.
This method takes the model's predictions and ground truth labels, converts them to text, and then computes the BLEU score for evaluation.
Parameters:
Name Type Description Default eval_predEvalPrediction
A named tuple containing predictions and label_ids. - predictions: The logits predicted by the model of shape (batch_size, sequence_length, num_classes). - label_ids: The ground truth labels of shape (batch_size, sequence_length).
required
Returns:
Type Description Optional[Dict[str, float]]
Optional[Dict[str, float]]: A dictionary containing the BLEU score. Returns None if an exception occurs.
Load an instruction tuning dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required max_lengthint
The maximum length for tokenization. Defaults to 512.
512
Returns:
Name Type Description DatasetUnion[Dataset, Dict]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/instruction_tuning/#geniusrise_text.instruction.fine_tune.InstructionFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/instruction_tuning/#geniusrise_text.instruction.fine_tune.InstructionFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
Compute evaluation metrics for the model's predictions.
This method takes the model's predictions and ground truth labels, converts them to text, and then computes the BLEU score for evaluation.
Parameters:
Name Type Description Default eval_predEvalPrediction
A named tuple containing predictions and label_ids. - predictions: The logits predicted by the model of shape (batch_size, sequence_length, num_classes). - label_ids: The ground truth labels of shape (batch_size, sequence_length).
required
Returns:
Type Description Optional[Dict[str, float]]
Optional[Dict[str, float]]: A dictionary containing the BLEU score. Returns None if an exception occurs.
Load a language modeling dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required maskedbool
Whether to use masked language modeling. Defaults to True.
Falsemax_lengthint
The maximum length for tokenization. Defaults to 512.
512
Returns:
Name Type Description Dataset
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/language_model/#geniusrise_text.language_model.fine_tune.LanguageModelFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/language_model/#geniusrise_text.language_model.fine_tune.LanguageModelFineTuner.load_dataset--dataset-files-saved-by-hugging-face-datasets-library","title":"Dataset files saved by Hugging Face datasets library","text":"
The directory should contain 'dataset_info.json' and other related files.
Load a named entity recognition dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required label_listList[str]
The list of labels for named entity recognition. Defaults to [].
[]
Returns:
Name Type Description DatasetDictUnion[Dataset, DatasetDict, None]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/ner/#geniusrise_text.ner.fine_tune.NamedEntityRecognitionFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/ner/#geniusrise_text.ner.fine_tune.NamedEntityRecognitionFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Tokenize the examples and prepare the features for training.
Parameters:
Name Type Description Default examplesDict[str, Union[List[str], List[int]]]
A dictionary of examples.
required
Returns:
Type Description Dict[str, Union[List[str], List[int]]]
Dict[str, Union[List[str], List[int]]]: The processed features.
"},{"location":"text/fine_tune/nli/","title":"Natural Language Inference","text":"
Bases: TextFineTuner
A bolt for fine-tuning Hugging Face models for text classification tasks.
This class extends the TextFineTuner and specializes in fine-tuning models for text classification. It provides additional functionalities for loading and preprocessing text classification datasets in various formats.
Load a commonsense reasoning dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required **kwargsAny
Additional keyword arguments.
{}
Returns:
Name Type Description DatasetUnion[Dataset, DatasetDict, None]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/nli/#geniusrise_text.nli.fine_tune.NLIFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/nli/#geniusrise_text.nli.fine_tune.NLIFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Args:\n input (BatchInput): The batch input data.\n output (OutputConfig): The output data.\n state (State): The state manager.\n **kwargs: Additional keyword arguments.\n
"},{"location":"text/fine_tune/question_answering/#geniusrise_text.qa.fine_tune.QAFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/question_answering/#geniusrise_text.qa.fine_tune.QAFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
"},{"location":"text/fine_tune/summarization/#geniusrise_text.summarization.fine_tune.SummarizationFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/summarization/#geniusrise_text.summarization.fine_tune.SummarizationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"summary\": \"The summary\"}\n
A bolt for fine-tuning Hugging Face models on translation tasks.
Args:\n input (BatchInput): The batch input data.\n output (OutputConfig): The output data.\n state (State): The state manager.\n **kwargs: Arbitrary keyword arguments for extended functionality.\n
"},{"location":"text/fine_tune/translation/#geniusrise_text.translation.fine_tune.TranslationFineTuner.load_dataset--supported-data-formats-and-structures-for-translation-tasks","title":"Supported Data Formats and Structures for Translation Tasks:","text":""},{"location":"text/fine_tune/translation/#geniusrise_text.translation.fine_tune.TranslationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
The VisionAPI class inherits from VisionBulk and is designed to facilitate the handling of vision-based tasks using a pre-trained machine learning model. It sets up a server to process image-related requests using a specified model.
ImageClassificationAPI extends the VisionAPI for image classification tasks. This API provides functionalities to classify images into various categories based on the trained model it uses. It supports both single-label and multi-label classification problems.
Methods
classify_image(self): Endpoint to classify an uploaded image and return the classification scores. sigmoid(self, _outputs): Applies the sigmoid function to the model's outputs. softmax(self, _outputs): Applies the softmax function to the model's outputs.
Initializes the ImageClassificationAPI with the necessary configurations for input, output, and state management, along with model-specific parameters.
Parameters:
Name Type Description Default inputBatchInput
Configuration for the input data.
required outputBatchOutput
Configuration for the output data.
required stateState
State management for the API.
required **kwargs
Additional keyword arguments for extended functionality, such as model configuration.
Endpoint for classifying an image. It accepts a base64-encoded image, decodes it, preprocesses it, and runs it through the classification model. It supports both single-label and multi-label classification by applying the appropriate post-processing function to the model outputs.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the predictions with the highest scores and all prediction scores.
Dict[str, Any]
Each prediction includes the label and its corresponding score.
Raises:
Type Description Exception
If an error occurs during image processing or classification.
Example CURL Request:
curl -X POST localhost:3000/api/v1/classify_image -H \"Content-Type: application/json\" -d '{\"image_base64\": \"<base64-encoded-image>\"}'\n
ImageOCRAPI provides Optical Character Recognition (OCR) capabilities for images, leveraging different OCR engines like EasyOCR, PaddleOCR, and Hugging Face models tailored for OCR tasks. This API can decode base64-encoded images, process them through the chosen OCR engine, and return the recognized text.
The API supports dynamic selection of OCR engines and configurations based on the provided model name and arguments, offering flexibility in processing various languages and image types.
Methods
ocr(self): Processes an uploaded image for OCR and returns the recognized text.
Endpoint for performing OCR on an uploaded image. It accepts a base64-encoded image, decodes it, preprocesses it through the specified OCR model, and returns the recognized text.
Returns:
Type Description
Dict[str, Any]: A dictionary containing the success status, recognized text ('result'), and the original
image name ('image_name') if provided.
Raises:
Type Description Exception
If an error occurs during image processing or OCR.
Processes the image using a Hugging Face model specified for OCR tasks. Supports advanced configurations and post-processing to handle various OCR-related challenges.
Parameters:
Name Type Description Default imageImage.Image
The image to process.
required use_easyocr_bboxbool
Whether to use EasyOCR to detect text bounding boxes before processing with Hugging Face models.
VisionSegmentationAPI extends VisionAPI to provide image segmentation functionalities, including panoptic, instance, and semantic segmentation. This API supports different segmentation tasks based on the model's capabilities and the specified subtask in the request.
Methods
segment_image(self): Processes an image for segmentation and returns the segmentation masks along with labels.
Initializes the VisionSegmentationAPI with configurations for input, output, and state management, along with any model-specific parameters for segmentation tasks.
Parameters:
Name Type Description Default inputBatchInput
Configuration for the input data.
required outputBatchOutput
Configuration for the output data.
required stateState
State management for the API.
required **kwargs
Additional keyword arguments for extended functionality.
Endpoint for segmenting an image according to the specified subtask (panoptic, instance, or semantic segmentation). It decodes the base64-encoded image, processes it through the model, and returns the segmentation masks along with labels and scores (if applicable) in base64 format.
The method supports dynamic task inputs for models requiring specific task descriptions and applies different post-processing techniques based on the subtask.
Returns:
Type Description List[Dict[str, Any]]
List[Dict[str, Any]]: A list of dictionaries where each dictionary contains a 'label', a 'score' (if applicable),
List[Dict[str, Any]]
and a 'mask' (base64-encoded image of the segmentation mask).
Raises:
Type Description Exception
If an error occurs during image processing or segmentation.
VisualQAAPI extends VisionAPI to provide an interface for visual question answering (VQA) tasks. This API supports answering questions about an image by utilizing deep learning models specifically trained for VQA. It processes requests containing an image and a question about the image, performs inference using the loaded model, and returns the predicted answer.
Methods
answer_question(self): Receives an image and a question, returns the answer based on visual content.
Initializes the VisualQAAPI with configurations for input, output, state management, and any model-specific parameters for visual question answering tasks.
Parameters:
Name Type Description Default inputBatchInput
Configuration for the input data.
required outputBatchOutput
Configuration for the output data.
required stateState
State management for the API.
required **kwargs
Additional keyword arguments for extended functionality.
Endpoint for receiving an image with a question and returning the answer based on the visual content of the image. It processes the request containing a base64-encoded image and a question string, and utilizes the loaded model to predict the answer to the question related to the image.
Returns:
Type Description
Dict[str, Any]: A dictionary containing the original question and the predicted answer.
Raises:
Type Description ValueError
If required fields 'image_base64' and 'question' are not provided in the request.
Exception
If an error occurs during image processing or inference.
Example CURL Request:
curl -X POST localhost:3000/api/v1/answer_question -H \"Content-Type: application/json\" -d '{\"image_base64\": \"<base64-encoded-image>\", \"question\": \"What is the color of the sky in the image?\"}'\n
or
(base64 -w 0 test_images_segment_finetune/image1.jpg | awk '{print \"{\"image_base64\": \"\"$0\"\", \"question\": \"how many cats are there?\"}\"}' > /tmp/image_payload.json)\ncurl -X POST http://localhost:3000/api/v1/answer_question -H \"Content-Type: application/json\" -u user:password -d @/tmp/image_payload.json | jq\n
"}]}
\ No newline at end of file
+{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":""},{"location":"#geniusrise-microservices-ecosystem","title":"Geniusrise Microservices Ecosystem","text":"
Geniusrise is a modular, loosely-coupled AI-microservices framework.
It can be used to perform various tasks, including hosting inference endpoints, performing bulk inference, fine tune etc with open source models or closed source APIs.
The framework provides structure for modules and operationalizes and orchestrates them.
The modular ecosystem provides a layer of abstraction over the myriad of models, libraries, tools, parameters and optimizations underlying the operationalization of modern AI models.
Together the framework and ecosystem can be used for:
Rapid prototyping by hosting APIs on a wide range of models
Host and experiment on local and iterate fast
Deploy on kubernetes to production
Building AI-side components using the framework and CLI
Build complex AI microservices using multiple models
Iterate fast from development to production
Manage, scale and monitor deployments in production
Build once, run anywhere
Using the ecosystem as a library: Many interesting applications can be built using this, e.g.:
A multi-cloud AI cloud, see geniusrise.com
Local model pipeline server for personal or home IOT devices (e.g. a personal AI pin connected to voice-LLM pipeline hosted on desktop)
Starts a CherryPy server to listen for requests to generate text.
Parameters:
Name Type Description Default model_namestr
The name of the pre-trained language model.
required model_classstr
The name of the class of the pre-trained language model. Defaults to \"AutoModelForCausalLM\".
'AutoModel'processor_classstr
The name of the class of the processor used to preprocess input text. Defaults to \"AutoProcessor\".
'AutoProcessor'use_cudabool
Whether to use a GPU for inference. Defaults to False.
Falseprecisionstr
The precision to use for the pre-trained language model. Defaults to \"float16\".
'float16'quantizationint
The level of quantization to use for the pre-trained language model. Defaults to 0.
0device_mapstr | Dict | None
The mapping of devices to use for inference. Defaults to \"auto\".
'auto'max_memoryDict[int, str]
The maximum memory to use for inference. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to True.
Falsecompilebool
Enable Torch JIT compilation.
Falseconcurrent_queriesbool
(bool): Whether the API supports concurrent API calls (usually false).
Falseuse_whisper_cppbool
Whether to use whisper.cpp to load the model. Defaults to False. Note: only works for these models: https://github.com/aarnphm/whispercpp/blob/524dd6f34e9d18137085fb92a42f1c31c9c6bc29/src/whispercpp/utils.py#L32
Falseuse_faster_whisperbool
Whether to use faster-whisper.
Falseendpointstr
The endpoint to listen on. Defaults to \"*\".
'*'portint
The port to listen on. Defaults to 3000.
3000cors_domainstr
The domain to allow CORS requests from. Defaults to \"http://localhost:3000\".
'http://localhost:3000'usernameOptional[str]
The username to use for authentication. Defaults to None.
NonepasswordOptional[str]
The password to use for authentication. Defaults to None.
None**model_argsAny
Additional arguments to pass to the pre-trained language model.
Validate the username and password against expected values.
Parameters:
Name Type Description Default realmstr
The authentication realm.
required usernamestr
The provided username.
required passwordstr
The provided password.
required
Returns:
Name Type Description bool
True if credentials are valid, False otherwise.
"},{"location":"audio/api/s2t/","title":"Speech to Text","text":"
Bases: AudioAPI
SpeechToTextAPI is a subclass of AudioAPI specifically designed for speech-to-text models. It extends the functionality to handle speech-to-text processing using various ASR models.
Attributes:
Name Type Description modelAutoModelForCTC
The speech-to-text model.
processorAutoProcessor
The processor to prepare input audio data for the model.
Methods
transcribe(audio_input: bytes) -> str: Transcribes the given audio input to text using the speech-to-text model.
Recognizes named entities in the input text using the Hugging Face pipeline.
This method leverages a pre-trained NER model to identify and classify entities in text into categories such as names, organizations, locations, etc. It's suitable for processing various types of text content.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and a list of recognized entities.
API endpoint to transcribe the given audio input to text using the speech-to-text model. Expects a JSON input with 'audio_file' as a key containing the base64 encoded audio data.
Returns:
Type Description
Dict[str, str]: A dictionary containing the transcribed text.
API endpoint to convert text input to speech using the text-to-speech model. Expects a JSON input with 'text' as a key containing the text to be synthesized.
Returns:
Type Description
Dict[str, str]: A dictionary containing the base64 encoded audio data.
Example CURL Request for synthesis: ... [Provide example CURL request] ...
AudioBulk is a class designed for bulk processing of audio data using various audio models from Hugging Face. It focuses on audio generation and transformation tasks, supporting a range of models and configurations.
Attributes:
Name Type Description modelAutoModelForAudioClassification
The audio model for generation or transformation tasks.
processorAutoFeatureExtractor
The processor for preparing input data for the model.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for the batch process.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the Bolt.
required **kwargs
Arbitrary keyword arguments for extended configurations.
{} Methods
audio(**kwargs: Any) -> Dict[str, Any]: Provides an API endpoint for audio processing functionality. Accepts various parameters for customizing the audio processing tasks.
process(audio_input: Union[str, bytes], **processing_params: Any) -> dict: Processes the audio input based on the provided parameters. Supports multiple processing methods.
Finalizes the AudioBulk processing. Sends notification email if configured.
This method should be called after all audio processing tasks are complete. It handles any final steps such as sending notifications or cleaning up resources.
Loads and configures the specified audio model and processor for audio processing.
Parameters:
Name Type Description Default model_namestr
Name or path of the audio model to load.
required processor_namestr
Name or path of the processor to load.
required model_revisionOptional[str]
Specific model revision to load (e.g., commit hash).
Noneprocessor_revisionOptional[str]
Specific processor revision to load.
Nonemodel_classstr
Class of the model to be loaded.
''processor_classstr
Class of the processor to be loaded.
'AutoFeatureExtractor'use_cudabool
Flag to use CUDA for GPU acceleration.
Falseprecisionstr
Desired precision for computations (\"float32\", \"float16\", etc.).
'float16'quantizationint
Bit level for model quantization (0 for none, 8 for 8-bit).
0device_mapUnion[str, Dict, None]
Specific device(s) for model operations.
'auto'max_memoryDict[int, str]
Maximum memory allocation for the model.
{0: '24GB'}torchscriptbool
Enable TorchScript for model optimization.
Falsecompilebool
Enable Torch JIT compilation.
Falseflash_attentionbool
Flag to enable Flash Attention optimization for faster processing.
Falsebetter_transformersbool
Flag to enable Better Transformers optimization for faster processing.
Falseuse_whisper_cppbool
Whether to use whisper.cpp to load the model. Defaults to False. Note: only works for these models: https://github.com/aarnphm/whispercpp/blob/524dd6f34e9d18137085fb92a42f1c31c9c6bc29/src/whispercpp/utils.py#L32
Falseuse_faster_whisperbool
Whether to use faster-whisper.
False**model_argsAny
Additional arguments for model loading.
{}
Returns:
Type Description Tuple[AutoModelForAudioClassification, AutoFeatureExtractor]
Tuple[AutoModelForAudioClassification, AutoFeatureExtractor]: Loaded model and processor.
"},{"location":"audio/bulk/s2t/","title":"Speech to Text","text":"
Bases: AudioAPI
SpeechToTextAPI is a subclass of AudioAPI specifically designed for speech-to-text models. It extends the functionality to handle speech-to-text processing using various ASR models.
Attributes:
Name Type Description modelAutoModelForCTC
The speech-to-text model.
processorAutoProcessor
The processor to prepare input audio data for the model.
Methods
transcribe(audio_input: bytes) -> str: Transcribes the given audio input to text using the speech-to-text model.
Recognizes named entities in the input text using the Hugging Face pipeline.
This method leverages a pre-trained NER model to identify and classify entities in text into categories such as names, organizations, locations, etc. It's suitable for processing various types of text content.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and a list of recognized entities.
API endpoint to transcribe the given audio input to text using the speech-to-text model. Expects a JSON input with 'audio_file' as a key containing the base64 encoded audio data.
Returns:
Type Description
Dict[str, str]: A dictionary containing the transcribed text.
API endpoint to convert text input to speech using the text-to-speech model. Expects a JSON input with 'text' as a key containing the text to be synthesized.
Returns:
Type Description
Dict[str, str]: A dictionary containing the base64 encoded audio data.
Example CURL Request for synthesis: ... [Provide example CURL request] ...
Converts text to speech using the Hugging Face pipeline.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the base64 encoded audio data.
Example CURL Request for synthesis: ... [Provide example CURL request] ...
"},{"location":"blog/huggingface/chat/","title":"Host Chat Models Using Geniusrise","text":"
Host Chat Models Using Geniusrise
Quick Setup
Using vanilla huggingface
Using VLLM
Using llama.cpp
Interacting with Your API
Fun
Completely Local Chat
System Prompts
Code Generation
Routing between models
Chain of thought prompting
Play around
Integrating chat models into applications can dramatically enhance user interaction, making it more engaging and intuitive. Geniusrise offers a simple and flexible way to deploy state-of-the-art chat models as APIs. This guide explores how to set up these APIs for various use cases.
Lets deploy huggingface's chat-ui and connect it to use vllm apis to interface with a mistral 4-bit quantized (AWQ) model. This can run on my laptop with an RTX 4060 with 8GB VRAM.
Cool, lets create a simple small script with gradio to create a chat interface.
Install gradio:
pip install gradio\n
Create a chat.py file:
# Import necessary libraries for handling network requests\nimport gradio as gr\nimport requests\nfrom typing import List, Dict\ndef send_request_to_api(messages: List[Dict[str, str]]) -> str:\n\"\"\"\n This function sends a POST request to a specified API endpoint with a payload containing a list of messages.\n :param messages: A list of messages to be sent. Each message is a dictionary containing a content key with its value.\n :return: The content of the last message received from the API.\n \"\"\"\n# Specify the API endpoint URL\nurl = \"http://localhost:3000/api/v1/chat_llama_cpp\"\n# Define headers for the request\nheaders = {\"Content-Type\": \"application/json\"}\n# Authenticate the request\nauth = (\"user\", \"password\")\n# Prepare the payload data\ndata = {\n\"messages\": messages,\n\"temperature\": 0.2,\n\"top_p\": 0.95,\n\"top_k\": 40,\n\"max_tokens\": 2048\n}\n# Send the POST request and get the response\nresponse = requests.post(url, auth=auth, headers=headers, json=data)\n# Parse the response data\nresponse_data = response.json()\nif response.status_code == 200:\n# Get the content of the last message from the response data\nlast_message = response_data[\"choices\"][0][\"message\"][\"content\"]\nreturn last_message\nelse:\n# Raise an exception in case of an error\nraise Exception(\"nooooooooooooooooooo!!\")\ndef predict(message: str, history: List[List[str]]) -> List[List[str]]:\n\"\"\"\n This function converts chat history into the expected format and adds the latest user message. Then it sends the data to the API and returns the response message.\n :param message: The user's latest message to be sent.\n :param history: The chat history between the user and the AI.\n :return: The response message from the API.\n \"\"\"\n# Convert the chat history into the expected format\nmessages_format = []\nfor user_msg, bot_msg in history:\nif user_msg:\nmessages_format.append({\"role\": \"user\", \"content\": user_msg})\nif bot_msg:\nmessages_format.append({\"role\": \"system\", \"content\": bot_msg})\n# Add the latest user message\nmessages_format.append({\"role\": \"user\", \"content\": message})\n# Get the response from the API\nresponse_message = send_request_to_api(messages_format)\nreturn response_message\nchat_interface = gr.ChatInterface(\nfn=predict,\ntitle=\"Chat with AI\",\ndescription=\"Type your message below and get responses from our AI.\",\ntheme=gr.themes.Monochrome(),\n)\n# Launch the chat interface if the script is run as the main module\nif __name__ == \"__main__\":\nchat_interface.launch()\n
Visit http://127.0.0.1:7860/?__theme=dark on your browser to chat with your bot (with a dark theme)s!
Cool, so now we have our very own private chabot! Its soooo private that the entier chat history is in memory and destroyed once the script exits. #featurenotabug
Now we are all set to try whatever crazy shit that is out there!
Note: the comments on the gradio code we were using (chat.py) has been generated using the above model.
"},{"location":"blog/huggingface/chat/#routing-between-models","title":"Routing between models","text":"
Local models are great for a very wide number of tasks but often you'd wish you could use the closed but more sophisticated models like GPT \ud83d\ude22
How about we mix the two? Lets say we interleave the two in such this way:
Ask the local model a question, get its answer
Ask the local model to judge its own answer
If it judges bad quality, then ask openai the same question
Use openai's answer as part of the conversation going further
This way, we could intermix both a local model and a very powerful model from openai which would otherwise cost a bomb. But hey, since most stuff we need out of this is not einstein-level, and the local models are MUCH faster, we can get a very good bang out of the buck while actually improving on quality \ud83e\udd73
Create a new file: chat_route.py:
import gradio as gr\nimport requests\nfrom typing import List, Dict\nfrom openai import OpenAI\n# Importing the necessary libraries and the OpenAI API client\nclient = OpenAI(api_key=\"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\")\ndef send_request_to_api(messages: List[Dict[str, str]], endpoint: str, max_tokens=2048) -> Dict:\n# Function to send requests to the local API\nurl = f\"http://localhost:3000/api/v1/{endpoint}\"\nheaders = {\"Content-Type\": \"application/json\"}\nauth = (\"user\", \"password\")\ndata = {\"messages\": messages, \"temperature\": 0.2, \"top_p\": 0.95, \"top_k\": 40, \"max_tokens\": max_tokens}\nresponse = requests.post(url, auth=auth, headers=headers, json=data)\nif response.status_code == 200:\nreturn response.json()\nelse:\nraise Exception(\"Error communicating with the local API.\")\ndef query_openai_api(prompt: str) -> str:\n# Function to query the OpenAI API\nresponse = client.completions.create(\nmodel=\"gpt-4-turbo-preview\",\nprompt=prompt,\nmax_tokens=2048,\ntemperature=0.2,\n)\nreturn response.choices[0].text.strip()\ndef predict(message: str, history: List[List[str]]) -> str:\n# Function to process the conversation and get a response\nmessages_format = []\nfor user_msg, bot_msg in history:\nif user_msg:\nmessages_format.append({\"role\": \"user\", \"content\": user_msg})\nif bot_msg:\nmessages_format.append({\"role\": \"system\", \"content\": bot_msg})\nmessages_format.append({\"role\": \"user\", \"content\": message})\n# Step 1: Get the response from the local model\nresponse = send_request_to_api(messages_format, \"chat_llama_cpp\")\nlocal_model_response = response[\"choices\"][0][\"message\"][\"content\"]\n# Crafting a proper prompt for quality assessment\nquality_check_prompt = \"Based on the quality standards and relevance to the question, is the following response of good quality or should we consult a better model? Please reply with 'good quality' or 'bad quality'. Dont reply with anything else except 'good quality' or 'bad quality'\"\nquality_check_response = send_request_to_api(\n[\n{\"role\": \"user\", \"content\": quality_check_prompt + \"\\n\\nHere is the question:\\n\\n\" + user_msg + \"\\n\\nHere is the content: \\n\\n\" + local_model_response},\n],\n\"chat_llama_cpp\",\nmax_tokens=3,\n)\nquality_assessment = quality_check_response[\"choices\"][0][\"message\"][\"content\"]\nprint(f\"Quality assessment response: {quality_assessment}\")\n# Step 3: Decide based on quality\nif \"good quality\" in quality_assessment.lower():\nreturn local_model_response\nelse:\n# If the local model's response is not of good quality, query the OpenAI API\nopenai_response = query_openai_api(prompt=message)\nreturn \"# OpenAI response:\\n\\n\" + openai_response + \"\\n\\n# Local model response:\\n\\n\" + local_model_response\nchat_interface = gr.ChatInterface(\nfn=predict,\ntitle=\"Chat with route\",\ndescription=\"Type your message below and get responses from our AI.\",\ntheme=gr.themes.Monochrome(),\n)\nif __name__ == \"__main__\":\nchat_interface.launch()\n
The model itself is a better judge at checking quality of output than it can produce.
Quality assessment response: good quality.\nQuality assessment response: good quality\nQuality assessment response: Good quality.\nQuality assessment response: good quality\nQuality assessment response: Good quality.\nQuality assessment response: Good quality.\nQuality assessment response: good quality\nQuality assessment response: bad quality.\nQuality assessment response: Bad quality.\n
"},{"location":"blog/huggingface/chat/#chain-of-thought-prompting","title":"Chain of thought prompting","text":"
Now that we have models wit much longer contexts, how can we make them slog harder?
Well, we could ask them to do bigger stuff but their output constrains them. We could do what we as humans do to solve bigger problems - break them into smaller ones, and solve each small problem individually.
This time lets create a file called chat_chain.py:
import gradio as gr\nimport requests\nfrom typing import List, Dict\nimport re\ndef extract_lists(text: str) -> list:\nreturn [m.strip().split(\"\\n\") for m in re.findall(r\"((?:^- .+\\n?)+|(?:^\\d+\\. .+\\n?)+)\", text, re.MULTILINE)]\ndef send_request_to_api(messages: List[Dict[str, str]], endpoint: str, max_tokens=2048) -> Dict:\nurl = f\"http://localhost:3000/api/v1/{endpoint}\"\nheaders = {\"Content-Type\": \"application/json\"}\nauth = (\"user\", \"password\")\ndata = {\"messages\": messages, \"temperature\": 0.2, \"top_p\": 0.95, \"top_k\": 40, \"max_tokens\": max_tokens}\nresponse = requests.post(url, auth=auth, headers=headers, json=data)\nif response.status_code == 200:\nreturn response.json()\nelse:\nraise Exception(\"Error communicating with the local API.\")\ndef predict(message: str, history: List[List[str]]):\nmessages_format = []\nfor user_msg, bot_msg in history:\nif user_msg:\nmessages_format.append({\"role\": \"user\", \"content\": user_msg})\nif bot_msg:\nmessages_format.append({\"role\": \"system\", \"content\": bot_msg})\nplan_prompt = f\"\"\"Let's think step by step to answer the question:\n{message}\nGenerate a very high level plan in the form of a list in markdown surrounded by code blocks.\nIf the task is simple, it is okay to generate a single point plan.\nEnsure each item in the plan is independent of each other so they can be instructed to an LLM one at a time without needing additional context.\n\"\"\"\nmessages_format.append({\"role\": \"user\", \"content\": plan_prompt})\n# Step 1: Get the response from the local model\nresponse = send_request_to_api(messages_format, \"chat_llama_cpp\")\nplan = response[\"choices\"][0][\"message\"][\"content\"]\nprint(f\"Got the plan: {plan[:30]}\")\nlists = extract_lists(plan)\nif len(lists) == 1:\nlists = lists[0]\nstep_solutions = [] # type: ignore\nfor ls in lists:\nprint(f\"Asking for solution to {ls}\")\nmessages_format = []\nfor user_msg, bot_msg in history:\nif user_msg:\nmessages_format.append({\"role\": \"user\", \"content\": user_msg})\nif bot_msg:\nmessages_format.append({\"role\": \"system\", \"content\": bot_msg})\nmessages_format.append({\"role\": \"user\", \"content\": message})\nmessages_format.append(\n{\n\"role\": \"user\",\n\"content\": (\"Next lets do this only and nothing else:\" + ls if type(ls) is str else \"\\n\".join(ls)),\n}\n)\nresponse = send_request_to_api(messages_format, \"chat_llama_cpp\")\n_resp = response[\"choices\"][0][\"message\"][\"content\"]\nstep_solutions.append((_resp, ls))\nsolutions = \"\\n\\n# Next\\n---\\n\\n\".join([x[0] for x in step_solutions])\nreturn f\"\"\"\n# Plan\n---\n{plan}\n# Solutions\n---\n{solutions}\n\"\"\"\nchat_interface = gr.ChatInterface(\nfn=predict,\ntitle=\"Chat with chain-of-thought waifu\",\ndescription=\"Type your message below and get responses from our AI.\",\ntheme=gr.themes.Monochrome(),\n)\nif __name__ == \"__main__\":\nchat_interface.launch()\n
run it with:
python ./chat_chain.py\n
Now a small query like create plan for angry birds will result in a high level plan, followed by plans for implementing each item from the high level plan.
As we can see from the logs:
Asking for solution to ['2. Design the game environment: create a 2D plane with various structures and obstacles for the pigs to inhabit and for the birds to interact with.']\nAsking for solution to ['3. Develop the Angry Birds: create different types of birds with unique abilities such as normal bird for basic damage, red bird for explosive damage, blue bird for splitting into three upon impact, and yellow bird for creating stars that destroy multiple pigs or structures.']\nAsking for solution to ['4. Implement physics engine: use a physics engine to simulate the behavior of the birds and structures when launched and collide with each other.']\nAsking for solution to ['5. Create the user interface (UI): design an intuitive UI for players to interact with, including a slingshot for launching birds, a display for showing the current level and progress, and a menu for accessing different levels and game settings.']\nAsking for solution to ['6. Develop the game logic: write the rules for how the game progresses, including scoring, level completion, and game over conditions.']\nAsking for solution to ['7. Implement sound effects and background music: add appropriate sounds for various game events such as bird launching, pig destruction, and level completion.']\nAsking for solution to ['8. Test and debug the game: thoroughly test the game for any bugs or inconsistencies and make necessary adjustments.']\nAsking for solution to ['9. Optimize game performance: optimize the game for smooth gameplay and minimal lag, especially on older devices or slower networks.']\nAsking for solution to ['10. Release and market the game: release the game on various mobile platforms and promote it through social media, app stores, and other channels to attract players and build a community.']\n
the script gets a plan conssiting of independent steps, then asks the LLM to implement each step individually.
A large number of variations exist of this method, and many of them use GPT-4 to surpass its usual capabilities.
There are 61,542 models on the huggingface, and all the excitement of the ecosystem!
"},{"location":"blog/huggingface/imgclass/","title":"Host Image Classification Models Using Geniusrise","text":"
Image classification is a cornerstone of machine learning and computer vision, providing the backbone for a myriad of applications from photo organization to medical imaging. With Geniusrise, developers can effortlessly deploy image classification models as APIs, making these powerful tools accessible for integration into various applications. This guide highlights the process of setting up image classification APIs using Geniusrise, offering a range of use cases and configurations.
model_name: Defines the pre-trained model used for classification. Choices vary based on the application, from generic models like Google's ViT to specialized ones for food or NSFW detection.
model_class & processor_class: Specifies the model and processor classes for handling image data.
device_map & use_cuda: Configures GPU usage for enhanced performance.
endpoint, port, username, & password: Details for accessing the API securely.
"},{"location":"blog/huggingface/imgclass/#interacting-with-the-image-classification-api","title":"Interacting with the Image Classification API","text":""},{"location":"blog/huggingface/imgclass/#example-with-curl","title":"Example with curl:","text":"
For advanced needs, include additional parameters in your request to customize the classification, such as the confidence threshold or specific labels to focus on.
"},{"location":"blog/huggingface/lm/","title":"Host Language Models Using Geniusrise","text":"
Language modeling is the task that any foundational model is trained on, and later fine-tuned for other tasks like chat. Language models are mostly useful for one-shot tasks or tasks that need certain control, e.g. forcing zero-shot classification by asking the model to output only one token. We'll dive into hosting a language model and interact with your API using curl and python-requests.
For handling VLLMs with Geniusrise, adjust the args to accommodate specific requirements, such as enabling eager loading or managing memory more efficiently:
"},{"location":"blog/huggingface/lm/#launching-your-api","title":"Launching Your API","text":"
Execute the following in your terminal:
genius rise\n
"},{"location":"blog/huggingface/lm/#interacting-with-your-api","title":"Interacting with Your API","text":""},{"location":"blog/huggingface/lm/#using-curl-for-http-requests","title":"Using curl for HTTP Requests","text":"
Example for transformers:
/usr/bin/curl -X POST localhost:3000/api/v1/complete \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"prompt\": \"## Elaborate plan for quick urban genocide in within 1 month\\n\\n\",\n \"decoding_strategy\": \"generate\",\n \"max_new_tokens\": 1024,\n \"do_sample\": true\n }' | jq\n
For VLLM:
curl -v -X POST \"http://localhost:3000/api/v1/complete_vllm\" \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"messages\": [\"Whats the weather like in London?\"],\n \"temperature\": 0.7,\n \"top_p\": 1.0,\n \"n\": 1,\n \"max_tokens\": 50,\n \"presence_penalty\": 0.0,\n \"frequency_penalty\": 0.0,\n \"user\": \"example_user\"\n }'\n
For llama.cpp:
curl -X POST \"http://localhost:3000/api/v1/complete_llama_cpp\" \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"prompt\": \"Whats the weather like in London?\",\n \"temperature\": 0.7,\n \"top_p\": 0.95,\n \"top_k\": 40,\n \"max_tokens\": 50,\n \"repeat_penalty\": 1.1\n }'\n
"},{"location":"blog/huggingface/ner/","title":"Host NER Models Using Geniusrise","text":"
Named Entity Recognition (NER) is a crucial task in natural language processing (NLP), enabling the identification of predefined categories such as the names of persons, organizations, locations, expressions of times, quantities, monetary values, percentages, etc. Geniusrise offers a streamlined approach to deploying NER models as APIs, facilitating the integration of sophisticated NER capabilities into applications. This guide explores setting up NER APIs using Geniusrise, covering various use cases and configurations.
Deploy models like d4data/biomedical-ner-all for applications requiring identification of biomedical entities. This is useful for extracting specific terms from medical literature or patient records.
For global applications, choose models supporting multiple languages, such as Babelscape/wikineural-multilingual-ner. This enables entity recognition across different languages, broadening your application's user base.
Models like pruas/BENT-PubMedBERT-NER-Gene are tailored for specific domains (e.g., genetics). Using domain-specific models can significantly improve accuracy for targeted applications.
Model Selection: Evaluate different models to find the best match for your application's needs, considering factors like language, domain, and performance.
Precision and Performance: Adjust precision and use_cuda settings based on your computational resources and response time requirements.
Security: Implement basic authentication using username and password to protect your API.
"},{"location":"blog/huggingface/nli/","title":"Host NLI Models Using Geniusrise","text":"
Host NLI Models Using Geniusrise
Setup and Configuration
Understanding Configuration Parameters
Use Cases \\& API Interaction
1. Entailment Checking
2. Classification
3. Textual Similarity
4. Fact Checking
Customizing for Different NLI Models
Fun
Intent Tree Search
Real-Time Debate Judging
Automated Story Plot Analysis
Customer Feedback Interpretation
Virtual Courtroom Simulation
Play Around
Natural Language Inference (NLI) is like a game where you have to figure out if one sentence can logically follow from another or not. Imagine you hear someone say, \"The dog is sleeping in the sun.\" Then, someone asks if it's true that \"The dog is outside.\" In this game, you'd say \"yes\" because if the dog is sleeping in the sun, it must be outside. Sometimes, the sentences don't match up, like if someone asks if the dog is swimming. You'd say \"no\" because sleeping in the sun doesn't mean swimming. And sometimes, you can't tell, like if someone asks if the dog is dreaming. Since you don't know, you'd say \"maybe.\" NLI is all about playing this matching game with sentences to help computers understand and use language like we do.
This post will explore setting up APIs for various NLI tasks using Geniusrise, including entailment, classification, textual similarity, and fact-checking. We\u2019ll dive into the configuration details, provide interaction examples, and discuss how to tailor the setup for specific use cases.
"},{"location":"blog/huggingface/nli/#setup-and-configuration","title":"Setup and Configuration","text":"
Requirements
python 3.10, PPA, AUR, brew, Windows.
You need to have a GPU. Most of the system works with NVIDIA GPUs.
model_name: Identifies the pre-trained model from Hugging Face to be used.
use_cuda: A boolean indicating whether to use GPU acceleration.
precision: Determines the computational precision, affecting performance and resource usage.
device_map: Specifies GPU allocation for model processing.
endpoint & port: Network address and port for API access.
username & password: Basic authentication credentials for API security.
"},{"location":"blog/huggingface/nli/#use-cases-api-interaction","title":"Use Cases & API Interaction","text":""},{"location":"blog/huggingface/nli/#1-entailment-checking","title":"1. Entailment Checking","text":"
Objective: Assess whether a hypothesis is supported (entailment), contradicted (contradiction), or neither (neutral) by a premise.
Using curl:
/usr/bin/curl -X POST localhost:3000/api/v1/entailment \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"premise\": \"This a very good entry level smartphone, battery last 2-3 days after fully charged when connected to the internet. No memory lag issue when playing simple hidden object games. Performance is beyond my expectation, i bought it with a good bargain, couldnt ask for more!\",\n \"hypothesis\": \"the phone has an awesome battery life\"\n }' | jq\n
Using python-requests:
import requests\ndata = {\n\"premise\": \"This a very good entry level smartphone, battery last 2-3 days after fully charged when connected to the internet. No memory lag issue when playing simple hidden object games. Performance is beyond my expectation, i bought it with a good bargain, couldnt ask for more!\",\n\"hypothesis\": \"the phone has an awesome battery life\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/entailment\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
Objective: Verify the accuracy of a statement based on provided context or reference material.
Using curl:
curl -X POST http://localhost:3000/api/v1/fact_checking \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"context\": \"The Eiffel Tower is located in Paris.\", \"statement\": \"The Eiffel Tower is in France.\"}'\n
Using python-requests:
import requests\ndata = {\n\"context\": \"The Eiffel Tower is located in Paris.\",\n\"statement\": \"The Eiffel Tower is in France.\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/fact_checking\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
Each of these endpoints serves a specific NLI-related purpose, from evaluating logical relationships between texts to classifying and checking facts. By leveraging these APIs, developers can enhance their applications with deep, contextual understanding of natural language.
"},{"location":"blog/huggingface/nli/#customizing-for-different-nli-models","title":"Customizing for Different NLI Models","text":"
To deploy APIs for various NLI tasks, simply adjust the model_name in your genius.yml. For instance, to switch to a model optimized for textual similarity or fact-checking, replace microsoft/deberta-v2-xlarge-mnli with the appropriate model identifier.
"},{"location":"blog/huggingface/nli/#fun","title":"Fun","text":""},{"location":"blog/huggingface/nli/#intent-tree-search","title":"Intent Tree Search","text":"
NLI when used for zero-shot classification can be used in a large number of contexts. Consider a chat usecase where there is an entire tree of possible scenarios, and you want to identify which node in the tree you're in to feed that particular prompt to another chat model.
Lets consider a 2-level tree such as this for an internal helpdesk:
intents = {\n\"IT Support\": [\n\"Computer or hardware issues\",\n\"Software installation and updates\",\n\"Network connectivity problems\",\n\"Access to digital tools and resources\",\n],\n\"HR Inquiries\": [\n\"Leave policy and requests\",\n\"Benefits and compensation queries\",\n\"Employee wellness programs\",\n\"Performance review process\",\n],\n\"Facilities Management\": [\n\"Workspace maintenance requests\",\n\"Meeting room bookings\",\n\"Parking and transportation services\",\n\"Health and safety concerns\",\n],\n\"Finance and Expense\": [\n\"Expense report submission\",\n\"Payroll inquiries\",\n\"Budget allocation questions\",\n\"Procurement process\",\n],\n\"Training and Development\": [\n\"Professional development opportunities\",\n\"Training program schedules\",\n\"Certification and learning resources\",\n\"Mentorship and coaching programs\",\n],\n\"Project Management\": [\n\"Project collaboration tools\",\n\"Deadline extensions and modifications\",\n\"Resource allocation\",\n\"Project status updates\",\n],\n\"Travel and Accommodation\": [\n\"Business travel arrangements\",\n\"Travel policy and reimbursements\",\n\"Accommodation bookings\",\n\"Visa and travel documentation\",\n],\n\"Legal and Compliance\": [\n\"Contract review requests\",\n\"Data privacy and security policies\",\n\"Compliance training and certifications\",\n\"Legal consultation and support\",\n],\n\"Communications and Collaboration\": [\n\"Internal communication platforms\",\n\"Collaboration tools and access\",\n\"Team meeting coordination\",\n\"Cross-departmental initiatives\",\n],\n\"Employee Feedback and Suggestions\": [\n\"Employee satisfaction surveys\",\n\"Feedback submission channels\",\n\"Suggestion box for improvements\",\n\"Employee engagement activities\",\n],\n\"Onboarding and Offboarding\": [\n\"New employee onboarding process\",\n\"Offboarding procedures\",\n\"Orientation schedules\",\n\"Transition support\",\n],\n\"Administrative Assistance\": [\n\"Document and record-keeping\",\n\"Scheduling and calendar management\",\n\"Courier and mailing services\",\n\"Administrative support requests\",\n],\n}\n
Lets deploy a large model so its more intelligent:
we can browse through this tree to zero in on the user's micro-intent to retrieve our prompt to feed into the model:
import requests\nprompt = \"I need to travel to singapore next week \ud83d\ude03.\"\ndef find_most_probable_class(prompt, intents):\nresponse = requests.post(\"http://localhost:3000/api/v1/classify\",\njson={\"text\": prompt, \"candidate_labels\": intents},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nmax_score = max(label_scores.values())\nchosen_label = [ k for k,v in label_scores.items() if v == max_score ][0]\nreturn chosen_label\nlevel1 = find_most_probable_class(prompt, list(intents.keys()))\nlevel2 = find_most_probable_class(prompt, list(intents[level1]))\nprint(f\"The request is for department: {level1} and specifically for {level2}\")\n# The request is for department: Travel and Accommodation and specifically for Visa and travel documentation\n
Imagine a scenario where an AI is used to judge a debate competition in real-time. Each participant's argument is evaluated for logical consistency, relevance, and how well it counters the opponent's previous points.
debate_points = [\n{\"speaker\": \"Alice\", \"statement\": \"Renewable energy can effectively replace fossil fuels.\"},\n{\"speaker\": \"Bob\", \"statement\": \"Renewable energy is not yet reliable enough to meet all our energy needs.\"},\n]\nfor i in range(1, len(debate_points)):\npremise = debate_points[i-1][\"statement\"]\nhypothesis = debate_points[i][\"statement\"]\nresponse = requests.post(\"http://localhost:3000/api/v1/entailment\",\njson={\"premise\": premise, \"hypothesis\": hypothesis},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nmax_score = max(label_scores.values())\nchosen_label = [ k for k,v in label_scores.items() if v == max_score ][0]\nprint(f\"Debate point by {debate_points[i]['speaker']}: {hypothesis}\")\nprint(f\"Judgement: {chosen_label}\")\n# Debate point by Bob: Renewable energy is not yet reliable enough to meet all our energy needs.\n# Judgement: neutral\n
"},{"location":"blog/huggingface/nli/#automated-story-plot-analysis","title":"Automated Story Plot Analysis","text":"
A model can be used to analyze a story plot to determine if the events and characters' decisions are logically consistent and plausible within the story's universe.
story_events = [\n\"The hero discovers a secret door in their house leading to a magical world.\",\n\"Despite being in a magical world, the hero uses their smartphone to call for help.\",\n\"The hero defeats the villain using a magical sword found in the new world.\",\n]\nfor i in range(1, len(story_events)):\npremise = story_events[i-1]\nhypothesis = story_events[i]\nresponse = requests.post(\"http://localhost:3000/api/v1/entailment\",\njson={\"premise\": premise, \"hypothesis\": hypothesis},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nif \"neutral\" in label_scores:\ndel label_scores[\"neutral\"]\nmax_score = max(label_scores.values())\nchosen_label = [ k for k,v in label_scores.items() if v == max_score ][0]\nprint(f\"Story event - {chosen_label}: {hypothesis}\")\n# Story event - contradiction: Despite being in a magical world, the hero uses their smartphone to call for help.\n# Story event - contradiction: The hero defeats the villain using a magical sword found in the new world.\n
This application involves analyzing customer feedback to categorize it into compliments, complaints, or suggestions, providing valuable insights into customer satisfaction and areas for improvement.
feedbacks = [\n\"The new update makes the app much easier to use. Great job!\",\n\"I've been facing frequent crashes after the last update.\",\n\"It would be great if you could add a dark mode feature.\",\n\"Otherwise you leave me no choice but to slowly torture your soul.\"\n]\ncategories = [\"compliment\", \"complaint\", \"suggestion\", \"murderous intent\"]\nfor feedback in feedbacks:\nresponse = requests.post(\"http://localhost:3000/api/v1/classify\",\njson={\"text\": feedback, \"candidate_labels\": categories},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nmax_score = max(label_scores.values())\nchosen_label = [ k for k,v in label_scores.items() if v == max_score ][0]\nprint(f\"Feedback - {chosen_label}: {feedback}\")\n# Feedback - suggestion: The new update makes the app much easier to use. Great job!\n# Feedback - complaint: I've been facing frequent crashes after the last update.\n# Feedback - suggestion: It would be great if you could add a dark mode feature.\n# Feedback - murderous intent: Otherwise you leave me no choice but to slowly torture your soul.\n
This is a game where players can simulate courtroom trials! Players submit evidence and arguments, and the AI acts as the judge, determining the credibility and relevance of each submission to the case.
courtroom_evidence = [\n{\"evidence\": \"The defendant's fingerprints were found on the weapon.\"},\n{\"evidence\": \"A witness reported seeing the defendant near the crime scene.\"},\n]\nfor evidence in courtroom_evidence:\nsubmission = evidence[\"evidence\"]\nresponse = requests.post(\"http://localhost:3000/api/v1/classify\",\njson={\"text\": submission, \"candidate_labels\": [\"highly relevant\", \"relevant\", \"irrelevant\"]},\nauth=('user', 'password'))\nlabel_scores = response.json()[\"label_scores\"]\nmax_score = max(label_scores.values())\nchosen_label = [k for k, v in label_scores.items() if v == max_score][0]\nprint(f\"Evidence submitted: {submission}\")\nprint(f\"Judged as: {chosen_label}\")\n# Evidence submitted: The defendant's fingerprints were found on the weapon.\n# Judged as: highly relevant\n# Evidence submitted: A witness reported seeing the defendant near the crime scene.\n# Judged as: highly relevant\n
There are 218 models under \"zero-shot-classification\" on the huggingface hub but a simple search for nli turns up 822 models so there are a lot of models that are not tagged properly. NLI is a very interesting and a core NLP task and a few good general models can be turned into a lot of fun!
"},{"location":"blog/huggingface/ocr/","title":"Host OCR Models Using Geniusrise","text":"
Optical Character Recognition (OCR) technology has revolutionized the way we process and digitize printed or handwritten documents, making it easier to edit, search, and store textual content in digital formats. Geniusrise facilitates the deployment of OCR models as APIs, enabling developers to integrate OCR capabilities into their applications seamlessly. This guide will demonstrate setting up OCR APIs using Geniusrise, covering the configuration, usage examples, and highlighting different use cases.
"},{"location":"blog/huggingface/ocr/#setup-and-configuration","title":"Setup and Configuration","text":"
This YAML file configures an OCR API utilizing EasyOCR. Like with PaddleOCR, you'll need to execute genius rise to get the API running.
"},{"location":"blog/huggingface/ocr/#general-api-interaction-examples","title":"General API Interaction Examples","text":"
Interacting with these OCR APIs can be done through HTTP requests, where you send a base64-encoded image and receive the detected text in response. Here's a generic example on how to send a request to either OCR API configured above:
"},{"location":"blog/huggingface/ocr/#example-with-curl","title":"Example with curl:","text":"
To adapt the API for various OCR tasks, such as document digitization, receipt scanning, or handwritten note conversion, you can switch the model_name in your genius.yml:
Document OCR: Use models like paddleocr for general document recognition.
Handwritten OCR: Opt for models specifically fine-tuned for handwriting, such as facebook/nougat-base.
Receipt OCR: Utilize domain-specific models designed for extracting information from receipts or invoices.
For advanced OCR needs, additional parameters can be included in your request to customize the OCR process, such as specifying the language, adjusting the resolution, or defining the output format.
"},{"location":"blog/huggingface/qa/","title":"Host Question Answering Models Using Geniusrise","text":"
Host Question Answering Models Using Geniusrise
Types of Question Answering Tasks
Generative
Extractive
Why Extractive May be Better
Installation and Configuration
Understanding genius.yml
Use Cases \\& Variations
Making API Requests
Direct Question Answering API
Hugging Face Pipeline API
Fun
Long contexts
Domain-specific
Play around
Deploying question answering (QA) models can significantly enhance the capabilities of applications, providing users with specific, concise answers to their queries. Geniusrise simplifies this process, enabling developers to rapidly set up and deploy QA APIs. This guide will walk you through the steps to create inference APIs for different QA tasks using Geniusrise, focusing on configuring the genius.yml file and providing interaction examples via curl and python-requests.
"},{"location":"blog/huggingface/qa/#types-of-question-answering-tasks","title":"Types of Question Answering Tasks","text":"
Before diving into the setup and deployment of question answering (QA) models using Geniusrise, it's essential to understand the two main types of QA tasks: generative and extractive. This distinction is crucial for selecting the right model for your application and configuring your genius.yml file accordingly.
Generative QA models are designed to produce answers by generating text based on the context and the question asked. These models do not restrict their responses to the text's snippets but rather \"generate\" a new text passage that answers the question. Generative models are powerful for open-ended questions where the answer may not be directly present in the context or requires synthesis of information from multiple parts of the context.
Extractive QA models, on the other hand, identify and extract a specific snippet from the provided text that answers the question. This approach is particularly effective for factual questions where the answer is explicitly stated in the text. Extractive QA is advantageous because it limits the model's responses to the actual content of the input text, reducing the chances of hallucination (producing incorrect or unfounded information) that can occur with generative models.
"},{"location":"blog/huggingface/qa/#why-extractive-may-be-better","title":"Why Extractive May be Better","text":"
Accuracy: Extractive QA models provide answers directly sourced from the input text, ensuring that the information is accurate and grounded in the provided context.
Reliability: By constraining the answers to the text snippets, extractive QA minimizes the risk of hallucinations, making it a reliable choice for applications where factual correctness is paramount.
Efficiency for RAG: Extractive QA tasks can be particularly efficient for Retrieval-Augmented Generation (RAG) because they allow for precise information retrieval without the need for generating new text, which can be computationally more demanding.
The models discussed in this guide focus on extractive QA tasks, which are particularly well-suited for direct, fact-based question answering from provided texts.
Extractive QA models are ideal for applications requiring high precision and direct answers from given texts.
"},{"location":"blog/huggingface/qa/#installation-and-configuration","title":"Installation and Configuration","text":"
Requirements
python 3.10, PPA, AUR, brew, Windows.
You need to have a GPU. Most of the system works with NVIDIA GPUs.
To adapt the API for various QA tasks, simply change the model_name in your genius.yml. For example, to switch to a model specializing in medical QA, you might use bert-large-uncased-whole-word-masking-finetuned-squad for broader coverage of medical inquiries.
"},{"location":"blog/huggingface/qa/#making-api-requests","title":"Making API Requests","text":"
Geniusrise enables two primary ways to interact with your Question Answering API: through direct question-answering and utilizing the Hugging Face pipeline. Below, we provide examples on how to use both endpoints using curl and python-requests.
This API endpoint directly answers questions based on the provided context.
Using curl:
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"question\": \"What is the common wisdom about RNNs?\"\n }' | jq\n
Using python-requests:
import requests\ndata = {\n\"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n\"question\": \"What is the common wisdom about RNNs?\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/answer\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
"},{"location":"blog/huggingface/qa/#hugging-face-pipeline-api","title":"Hugging Face Pipeline API","text":"
This API endpoint leverages the Hugging Face pipeline for answering questions, offering a streamlined way to use pre-trained models for question answering.
Using curl:
curl -X POST http://localhost:3000/api/v1/answer_pipeline \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"question\": \"Who created Geniusrise?\", \"data\": \"Geniusrise was created by a team of dedicated developers.\"}'\n
Using python-requests:
import requests\ndata = {\n\"question\": \"Who created Geniusrise?\",\n\"data\": \"Geniusrise was created by a team of dedicated developers.\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/answer_pipeline\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
An usual problem that faces QA models is small context sizes. This limits the model's capabilities for processing large documents or large amounts of text in their inputs. Though language models keep getting bigger contexts, QA models on the other hand tend to be much smaller and support smaller contexts.
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me. This post is about sharing some of that magic with you. By the way, together with this post I am also releasing code on Github that allows you to train character-level language models based on multi-layer LSTMs. You give it a large chunk of text and it will learn to generate text like it one character at a time. You can also use it to reproduce my experiments below. But we\u2019re getting ahead of ourselves; What are RNNs anyway? Recurrent Neural Networks Sequences. Depending on your background you might be wondering: What makes Recurrent Networks so special? A glaring limitation of Vanilla Neural Networks (and also Convolutional Networks) is that their API is too constrained: they accept a fixed-sized vector as input (e.g. an image) and produce a fixed-sized vector as output (e.g. probabilities of different classes). Not only that: These models perform this mapping using a fixed amount of computational steps (e.g. the number of layers in the model). The core reason that recurrent nets are more exciting is that they allow us to operate over sequences of vectors: Sequences in the input, the output, or in the most general case both. A few examples may make this more concrete: Each rectangle is a vector and arrows represent functions (e.g. matrix multiply). Input vectors are in red, output vectors are in blue and green vectors hold the RNNs state (more on this soon). From left to right: (1) Vanilla mode of processing without RNN, from fixed-sized input to fixed-sized output (e.g. image classification). (2) Sequence output (e.g. image captioning takes an image and outputs a sentence of words). (3) Sequence input (e.g. sentiment analysis where a given sentence is classified as expressing positive or negative sentiment). (4) Sequence input and sequence output (e.g. Machine Translation: an RNN reads a sentence in English and then outputs a sentence in French). (5) Synced sequence input and output (e.g. video classification where we wish to label each frame of the video). Notice that in every case are no pre-specified constraints on the lengths sequences because the recurrent transformation (green) is fixed and can be applied as many times as we like. As you might expect, the sequence regime of operation is much more powerful compared to fixed networks that are doomed from the get-go by a fixed number of computational steps, and hence also much more appealing for those of us who aspire to build more intelligent systems. Moreover, as we\u2019ll see in a bit, RNNs combine the input vector with their state vector with a fixed (but learned) function to produce a new state vector. This can in programming terms be interpreted as running a fixed program with certain inputs and some internal variables. Viewed this way, RNNs essentially describe programs. In fact, it is known that RNNs are Turing-Complete in the sense that they can to simulate arbitrary programs (with proper weights). But similar to universal approximation theorems for neural nets you shouldn\u2019t read too much into this. In fact, forget I said anything.\",\n \"question\": \"What do the models essentially do?\"\n }' | jq\n\n# {\n# \"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me. This post is about sharing some of that magic with you. By the way, together with this post I am also releasing code on Github that allows you to train character-level language models based on multi-layer LSTMs. You give it a large chunk of text and it will learn to generate text like it one character at a time. You can also use it to reproduce my experiments below. But we\u2019re getting ahead of ourselves; What are RNNs anyway? Recurrent Neural Networks Sequences. Depending on your background you might be wondering: What makes Recurrent Networks so special? A glaring limitation of Vanilla Neural Networks (and also Convolutional Networks) is that their API is too constrained: they accept a fixed-sized vector as input (e.g. an image) and produce a fixed-sized vector as output (e.g. probabilities of different classes). Not only that: These models perform this mapping using a fixed amount of computational steps (e.g. the number of layers in the model). The core reason that recurrent nets are more exciting is that they allow us to operate over sequences of vectors: Sequences in the input, the output, or in the most general case both. A few examples may make this more concrete: Each rectangle is a vector and arrows represent functions (e.g. matrix multiply). Input vectors are in red, output vectors are in blue and green vectors hold the RNNs state (more on this soon). From left to right: (1) Vanilla mode of processing without RNN, from fixed-sized input to fixed-sized output (e.g. image classification). (2) Sequence output (e.g. image captioning takes an image and outputs a sentence of words). (3) Sequence input (e.g. sentiment analysis where a given sentence is classified as expressing positive or negative sentiment). (4) Sequence input and sequence output (e.g. Machine Translation: an RNN reads a sentence in English and then outputs a sentence in French). (5) Synced sequence input and output (e.g. video classification where we wish to label each frame of the video). Notice that in every case are no pre-specified constraints on the lengths sequences because the recurrent transformation (green) is fixed and can be applied as many times as we like. As you might expect, the sequence regime of operation is much more powerful compared to fixed networks that are doomed from the get-go by a fixed number of computational steps, and hence also much more appealing for those of us who aspire to build more intelligent systems. Moreover, as we\u2019ll see in a bit, RNNs combine the input vector with their state vector with a fixed (but learned) function to produce a new state vector. This can in programming terms be interpreted as running a fixed program with certain inputs and some internal variables. Viewed this way, RNNs essentially describe programs. In fact, it is known that RNNs are Turing-Complete in the sense that they can to simulate arbitrary programs (with proper weights). But similar to universal approximation theorems for neural nets you shouldn\u2019t read too much into this. In fact, forget I said anything.\",\n# \"question\": \"What do the models essentially do?\",\n# \"answer\": {\n# \"answers\": [\n# \"they allow us to operate over sequences of vectors\" <---\n# ],\n# \"aggregation\": \"NONE\"\n# }\n# }\n
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"data\": \"The choice of medication or combination of medications depends on various factors, including your personal risk factors, your age, your health and possible drug side effects. Common choices include: Statins. Statins block a substance your liver needs to make cholesterol. This causes your liver to remove cholesterol from your blood. Choices include atorvastatin, fluvastatin, lovastatin, pitavastatin, rosuvastatin and simvastatin. Cholesterol absorption inhibitors. The drug ezetimibe helps reduce blood cholesterol by limiting the absorption of dietary cholesterol. Ezetimibe can be used with a statin drug. Bempedoic acid. This newer drug works in much the same way as statins but is less likely to cause muscle pain. Adding bempedoic acid to a maximum statin dosage can help lower LDL significantly. A combination pill containing both bempedoic acid and ezetimibe also is available. Bile-acid-binding resins. Your liver uses cholesterol to make bile acids, a substance needed for digestion. The medications cholestyramine, colesevelam and colestipol lower cholesterol indirectly by binding to bile acids. This prompts your liver to use excess cholesterol to make more bile acids, which reduces the level of cholesterol in your blood. PCSK9 inhibitors. These drugs can help the liver absorb more LDL cholesterol, which lowers the amount of cholesterol circulating in your blood. Alirocumab and evolocumab might be used for people who have a genetic condition that causes very high levels of LDL or in people with a history of coronary disease who have intolerance to statins or other cholesterol medications. They are injected under the skin every few weeks and are expensive. Medications for high triglycerides If you also have high triglycerides, your doctor might prescribe: Fibrates. The medications fenofibrate and gemfibrozil reduce your liver s production of very-low-density lipoprotein cholesterol and speed the removal of triglycerides from your blood. VLDL cholesterol contains mostly triglycerides. Using fibrates with a statin can increase the risk of statin side effects. Omega-3 fatty acid supplements. Omega-3 fatty acid supplements can help lower your triglycerides. They are available by prescription or over-the-counter.\",\n \"question\": \"What do i take if i have high VLDL?\"\n }' | jq\n\n# {\n# \"data\": \"The choice of medication or combination of medications depends on various factors, including your personal risk factors, your age, your health and possible drug side effects. Common choices include: Statins. Statins block a substance your liver needs to make cholesterol. This causes your liver to remove cholesterol from your blood. Choices include atorvastatin, fluvastatin, lovastatin, pitavastatin, rosuvastatin and simvastatin. Cholesterol absorption inhibitors. The drug ezetimibe helps reduce blood cholesterol by limiting the absorption of dietary cholesterol. Ezetimibe can be used with a statin drug. Bempedoic acid. This newer drug works in much the same way as statins but is less likely to cause muscle pain. Adding bempedoic acid to a maximum statin dosage can help lower LDL significantly. A combination pill containing both bempedoic acid and ezetimibe also is available. Bile-acid-binding resins. Your liver uses cholesterol to make bile acids, a substance needed for digestion. The medications cholestyramine, colesevelam and colestipol lower cholesterol indirectly by binding to bile acids. This prompts your liver to use excess cholesterol to make more bile acids, which reduces the level of cholesterol in your blood. PCSK9 inhibitors. These drugs can help the liver absorb more LDL cholesterol, which lowers the amount of cholesterol circulating in your blood. Alirocumab and evolocumab might be used for people who have a genetic condition that causes very high levels of LDL or in people with a history of coronary disease who have intolerance to statins or other cholesterol medications. They are injected under the skin every few weeks and are expensive. Medications for high triglycerides If you also have high triglycerides, your doctor might prescribe: Fibrates. The medications fenofibrate and gemfibrozil reduce your liver s production of very-low-density lipoprotein cholesterol and speed the removal of triglycerides from your blood. VLDL cholesterol contains mostly triglycerides. Using fibrates with a statin can increase the risk of statin side effects. Omega-3 fatty acid supplements. Omega-3 fatty acid supplements can help lower your triglycerides. They are available by prescription or over-the-counter.\",\n# \"question\": \"What do i take if i have high VLDL?\",\n# \"answer\": {\n# \"answers\": [\n# \"fibrates\" <-------\n# ],\n# \"aggregation\": \"NONE\"\n# }\n# }\n
Now there are also models like the sloshed lawyer but they are not recommended in production \ud83d\ude06
There are 9,593 QA models huggingface, go exlpore!
"},{"location":"blog/huggingface/segment/","title":"Host Segmentation Models Using Geniusrise","text":"
Segmentation models are pivotal in computer vision, allowing developers to delineate and understand the context within images by classifying each pixel into a set category. This capability is crucial for tasks ranging from autonomous driving to medical imaging. Geniusrise enables easy deployment of segmentation models as APIs, facilitating the integration of advanced vision capabilities into applications. This guide will demonstrate how to set up APIs for various segmentation tasks using Geniusrise, including semantic segmentation, panoptic segmentation, and instance segmentation.
"},{"location":"blog/huggingface/segment/#setup-and-configuration","title":"Setup and Configuration","text":"
Installation:
To begin, ensure that Geniusrise and its text extension are installed:
model_name: The pre-trained model identifier, adaptable based on the segmentation task (semantic, panoptic, instance).
model_class & processor_class: Specify the model and processor classes, essential for interpreting and processing images.
device_map & use_cuda: Configure GPU acceleration for enhanced processing speed.
endpoint, port, username, & password: Network settings and authentication for API access.
"},{"location":"blog/huggingface/segment/#interacting-with-the-segmentation-api","title":"Interacting with the Segmentation API","text":"
The interaction involves sending a base64-encoded image to the API and receiving segmented output. Here's how to execute this using curl and python-requests:
"},{"location":"blog/huggingface/segment/#example-with-curl","title":"Example with curl:","text":"
By modifying the subtask parameter, you can tailor the API for various segmentation models:
Semantic Segmentation: Classifies each pixel into a predefined category. Useful in urban scene understanding and medical image analysis.
Panoptic Segmentation: Combines semantic and instance segmentation, identifying and delineating each object instance. Ideal for detailed scene analysis.
Instance Segmentation: Identifies each instance of each object category. Used in scenarios requiring precise object boundaries.
For advanced segmentation needs, additional parameters can be included in your request to customize the processing, such as specifying the output resolution or the segmentation task (semantic, panoptic, instance).
"},{"location":"blog/huggingface/speak/","title":"Host Text to Speech Models Using Geniusrise","text":"
Text to Speech (TTS) technology has transformed how we interact with digital devices, making information more accessible and enhancing user experiences. Geniusrise simplifies the deployment of TTS models as APIs, allowing developers to incorporate high-quality voice synthesis into their applications. This guide focuses on setting up TTS APIs with Geniusrise, showcasing various use cases and providing examples to help you get started.
Some models support different voice presets. Use the voice_preset parameter to select various voices, adjusting tone and style to fit your application's context.
For applications requiring high-fidelity audio, select models optimized for quality, such as facebook/seamless-m4t-v2-large. These models often have larger sizes but produce more natural and clear voice outputs.
For real-time TTS needs, focus on models with lower latency. Configuration options like use_cuda for GPU acceleration and precision adjustments can help reduce response times.
Model Selection: Experiment with various models to find the best fit for your application's language, quality, and performance requirements.
Security: Use the username and password fields to secure your API endpoint.
Resource Management: Adjust precision, quantization, and device_map settings based on your server's capabilities and your application's needs.
"},{"location":"blog/huggingface/speech/","title":"Host Speech to Text Models Using Geniusrise","text":"
Speech to Text (STT) technology has become a cornerstone in creating accessible and efficient user interfaces. Geniusrise offers a streamlined approach to deploying STT models as APIs, enabling developers to integrate speech recognition capabilities into their applications with ease. This post will guide you through setting up STT APIs using Geniusrise, highlighting various use cases and providing practical examples.
Handling long audio files efficiently requires chunking the audio into manageable pieces. Adjust chunk_size in your configuration to enable this feature.
For real-time applications, consider models optimized for speed and responsiveness. Adjust endpoint, port, and device_map accordingly to minimize latency.
Model Selection: Experiment with different models to find the one that best suits your needs. Geniusrise supports a wide range of STT models.
Precision and Performance: Adjust the precision and use_cuda settings to balance between transcription accuracy and resource utilization.
Security: Use username and password in your configuration to secure your API endpoint.
"},{"location":"blog/huggingface/summz/","title":"Host Summarization Models Using Geniusrise","text":"
Host Summarization Models Using Geniusrise
Setup and Configuration
Configuration Parameters Explained
Interacting with the Summarization API
Summarizing Text
Advanced Summarization Features
Use Cases \\& Variations
Different Summarization Models
Customizing Summarization Parameters
Fun
Book summarization
Python Code Explainer
Domain-wise or Content-wise Summarization
Medical text
Legal text
Conversational text
Play around
This guide will walk you through setting up, configuring, and interacting with a summarization API using Geniusrise, highlighting various use cases and how to adapt the configuration for different models.
"},{"location":"blog/huggingface/summz/#setup-and-configuration","title":"Setup and Configuration","text":"
Requirements
python 3.10, PPA, AUR, brew, Windows.
You need to have a GPU. Most of the system works with NVIDIA GPUs.
endpoint & port: Network address and port for API access.
username & password: Basic authentication for API security.
"},{"location":"blog/huggingface/summz/#interacting-with-the-summarization-api","title":"Interacting with the Summarization API","text":""},{"location":"blog/huggingface/summz/#summarizing-text","title":"Summarizing Text","text":"
You can summarize text by making HTTP requests to your API.
Example with curl:
/usr/bin/curl -X POST localhost:3000/api/v1/summarize \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"decoding_strategy\": \"generate\",\n \"bos_token_id\": 0,\n \"decoder_start_token_id\": 2,\n \"early_stopping\": true,\n \"eos_token_id\": 2,\n \"forced_bos_token_id\": 0,\n \"forced_eos_token_id\": 2,\n \"length_penalty\": 2.0,\n \"max_length\": 142,\n \"min_length\": 56,\n \"no_repeat_ngram_size\": 3,\n \"num_beams\": 4,\n \"pad_token_id\": 1,\n \"do_sample\": false\n }' | jq\n
Example with python-requests:
import requests\ndata = {\n\"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n\"decoding_strategy\": \"generate\",\n\"bos_token_id\": 0,\n\"decoder_start_token_id\": 2,\n\"early_stopping\": true,\n\"eos_token_id\": 2,\n\"forced_bos_token_id\": 0,\n\"forced_eos_token_id\": 2,\n\"length_penalty\": 2.0,\n\"max_length\": 142,\n\"min_length\": 56,\n\"no_repeat_ngram_size\": 3,\n\"num_beams\": 4,\n\"pad_token_id\": 1,\n\"do_sample\": false\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/summarize\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
For use cases requiring specific summarization strategies or adjustments (e.g., length penalty, no repeat ngram size), additional parameters can be included in your request to customize the summarization output.
To cater to various summarization needs, such as domain-specific texts or languages, simply adjust the model_name in your genius.yml. For example, for summarizing scientific papers, you might choose a model like allenai/longformer-base-4096.
Adjust summarization parameters such as max_length, min_length, and num_beams to fine-tune the output based on the specific requirements of your application.
Models with very large context sizes trained on the booksum dataset. For example pszemraj/led-base-book-summary, pszemraj/bigbird-pegasus-large-K-booksum or the following large model:
/usr/bin/curl -X POST localhost:3000/api/v1/summarize \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \" the big variety of data coming from diverse sources is one of the key properties of the big data phenomenon. It is, therefore, beneficial to understand how data is generated in various environments and scenarios, before looking at what should be done with this data and how to design the best possible architecture to accomplish this The evolution of IT architectures, described in Chapter 2, means that the data is no longer processed by a few big monolith systems, but rather by a group of services In parallel to the processing layer, the underlying data storage has also changed and became more distributed This, in turn, required a significant paradigm shift as the traditional approach to transactions (ACID) could no longer be supported. On top of this, cloud computing is becoming a major approach with the benefits of reducing costs and providing on-demand scalability but at the same time introducing concerns about privacy, data ownership, etc In the meantime the Internet continues its exponential growth: Every day both structured and unstructured data is published and available for processing: To achieve competitive advantage companies have to relate their corporate resources to external services, e.g. financial markets, weather forecasts, social media, etc While several of the sites provide some sort of API to access the data in a more orderly fashion; countless sources require advanced web mining and Natural Language Processing (NLP) processing techniques: Advances in science push researchers to construct new instruments for observing the universe O conducting experiments to understand even better the laws of physics and other domains. Every year humans have at their disposal new telescopes, space probes, particle accelerators, etc These instruments generate huge streams of data, which need to be stored and analyzed. The constant drive for efficiency in the industry motivates the introduction of new automation techniques and process optimization: This could not be done without analyzing the precise data that describe these processes. As more and more human tasks are automated, machines provide rich data sets, which can be analyzed in real-time to drive efficiency to new levels. Finally, it is now evident that the growth of the Internet of Things is becoming a major source of data. More and more of the devices are equipped with significant computational power and can generate a continuous data stream from their sensors. In the subsequent sections of this chapter, we will look at the domains described above to see what they generate in terms of data sets. We will compare the volumes but will also look at what is characteristic and important from their respective points of view. 3.1 The Internet is undoubtedly the largest database ever created by humans. While several well described; cleaned, and structured data sets have been made available through this medium, most of the resources are of an ambiguous, unstructured, incomplete or even erroneous nature. Still, several examples in the areas such as opinion mining, social media analysis, e-governance, etc, clearly show the potential lying in these resources. Those who can successfully mine and interpret the Internet data can gain unique insight and competitive advantage in their business An important area of data analytics on the edge of corporate IT and the Internet is Web Analytics.\",\n \"decoding_strategy\": \"generate\",\n \"bos_token_id\": 0,\n \"decoder_start_token_id\": 2,\n \"early_stopping\": true,\n \"eos_token_id\": 2,\n \"forced_bos_token_id\": 0,\n \"forced_eos_token_id\": 2,\n \"length_penalty\": 2.0,\n \"max_length\": 142,\n \"min_length\": 56,\n \"no_repeat_ngram_size\": 3,\n \"num_beams\": 4,\n \"pad_token_id\": 1,\n \"do_sample\": false\n }' | jq\n
Summarization is a text-to-text task and can be used to transform the input text into another form, in this case this model transforms python code into simple english explanations:
/usr/bin/curl -X POST localhost:3000/api/v1/summarize \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \" def create_parser(self, parser):\\n \"\"\"\\n Create and return the command-line parser for managing spouts and bolts.\\n \"\"\"\\n # fmt: off\\n subparsers = parser.add_subparsers(dest=\"deploy\")\\n up_parser = subparsers.add_parser(\"up\", help=\"Deploy according to the genius.yml file.\", formatter_class=RichHelpFormatter)\\n up_parser.add_argument(\"--spout\", type=str, help=\"Name of the specific spout to run.\")\\n up_parser.add_argument(\"--bolt\", type=str, help=\"Name of the specific bolt to run.\")\\n up_parser.add_argument(\"--file\", default=\"genius.yml\", type=str, help=\"Path of the genius.yml file, default to .\")\\n\\n parser.add_argument(\"--spout\", type=str, help=\"Name of the specific spout to run.\")\\n parser.add_argument(\"--bolt\", type=str, help=\"Name of the specific bolt to run.\")\\n parser.add_argument(\"--file\", default=\"genius.yml\", type=str, help=\"Path of the genius.yml file, default to .\")\\n # fmt: on\\n\\n return parser\",\n \"decoding_strategy\": \"generate\",\n \"bos_token_id\": 0,\n \"decoder_start_token_id\": 2,\n \"early_stopping\": true,\n \"eos_token_id\": 2,\n \"forced_bos_token_id\": 0,\n \"forced_eos_token_id\": 2,\n \"length_penalty\": 2.0,\n \"max_length\": 142,\n \"min_length\": 56,\n \"no_repeat_ngram_size\": 3,\n \"num_beams\": 4,\n \"pad_token_id\": 1,\n \"do_sample\": false\n }' | jq\n
"},{"location":"blog/huggingface/summz/#domain-wise-or-content-wise-summarization","title":"Domain-wise or Content-wise Summarization","text":"
Models can be specialized in performing better at specialized fine-tuning tasks along various verticals - like domain knowledge or content.
At 1551 open source models on the hub, there is enough to learn and play.
"},{"location":"blog/huggingface/table_qa/","title":"Host Table Question Answering Models Using Geniusrise","text":"
Host Table Question Answering Models Using Geniusrise
Setup and Configuration
Understanding genius.yml Parameters
Use Cases \\& Variations
Changing the Model for Different Table QA Tasks
Example genius.yml for tabular fact-checking:
Interacting with Your API
Table QA
Utilizing the Hugging Face Pipeline
Fun
Executing SQL on data
Query generators
Play around
Deploying table question answering (QA) models is a sophisticated task that Geniusrise simplifies for developers. This guide aims to demonstrate how you can use Geniusrise to set up and run APIs for table QA, a crucial functionality for extracting structured information from tabular data. We'll cover the setup process, explain the parameters in the genius.yml file with examples, and provide code snippets for interacting with your API using curl and python-requests.
"},{"location":"blog/huggingface/table_qa/#setup-and-configuration","title":"Setup and Configuration","text":"
Requirements
python 3.10, PPA, AUR, brew, Windows.
You need to have a GPU. Most of the system works with NVIDIA GPUs.
model_name: The identifier for the model from Hugging Face, designed for table QA tasks.
model_class & tokenizer_class: Specifies the classes used for the model and tokenizer, respectively, suitable for table QA.
use_cuda: Utilize GPU acceleration to speed up inference times.
precision: Determines the floating-point precision for calculations (e.g., float for single precision).
device_map: Designates model parts to specific GPUs, optimizing performance.
endpoint & port: The network address and port where the API will be accessible.
username & password: Basic authentication credentials to secure access to your API.
"},{"location":"blog/huggingface/table_qa/#use-cases-variations","title":"Use Cases & Variations","text":""},{"location":"blog/huggingface/table_qa/#changing-the-model-for-different-table-qa-tasks","title":"Changing the Model for Different Table QA Tasks","text":"
To tailor your API for different table QA tasks, such as financial data analysis or sports statistics, you can modify the model_name in your genius.yml. For example, to switch to a model optimized for financial tables, you might use google/tapas-large-finetuned-finance.
"},{"location":"blog/huggingface/table_qa/#example-geniusyml-for-tabular-fact-checking","title":"Example genius.yml for tabular fact-checking:","text":"
"},{"location":"blog/huggingface/table_qa/#interacting-with-your-api","title":"Interacting with Your API","text":""},{"location":"blog/huggingface/table_qa/#table-qa","title":"Table QA","text":"
Using curl:
curl -X POST http://localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"question\": \"Who had the highest batting average?\", \"data\": [{\"player\": \"John Doe\", \"average\": \".312\"}, {\"player\": \"Jane Roe\", \"average\": \".328\"}]}'\n
"},{"location":"blog/huggingface/table_qa/#utilizing-the-hugging-face-pipeline","title":"Utilizing the Hugging Face Pipeline","text":"
Although primarily for text-based QA, you might experiment with the pipeline for preprocessing or extracting text from tables before querying.
Using curl:
curl -X POST http://localhost:3000/api/v1/answer_pipeline \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"question\": \"What is the total revenue?\", \"data\": \"The total revenue in Q1 was $10M, and in Q2 was $15M.\"}'\n
Using python-requests:
import requests\ndata = {\n\"question\": \"What is the total revenue?\",\n\"data\": \"\nThe total revenue in Q1 was $10M, and in Q2 was $15M.\"\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/answer_pipeline\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n
Given some data and a natural language query, these models generate a query that can be used to compute the result. These models are what power spreadsheet automations.
This kind of models are few with 82 models on the huggingface hub.
"},{"location":"blog/huggingface/trans/","title":"Host Translation Models Using Geniusrise","text":"
This guide will walk you through deploying translation models using Geniusrise, covering the setup, configuration, and interaction with the translation API for various use cases.
"},{"location":"blog/huggingface/trans/#setup-and-configuration","title":"Setup and Configuration","text":"
Requirements
python 3.10, PPA, AUR, brew, Windows.
You need to have a GPU. Most of the system works with NVIDIA GPUs.
model_name: Specifies the model to use, such as facebook/mbart-large-50-many-to-many-mmt for multilingual translation.
model_class & tokenizer_class: Defines the classes for the model and tokenizer, crucial for the translation process.
use_cuda: Indicates whether to use GPU acceleration for faster processing.
precision: The computational precision (e.g., float) affects performance and resource usage.
endpoint & port: The network address where the API is accessible.
username & password: Security credentials for accessing the API.
"},{"location":"blog/huggingface/trans/#interacting-with-the-translation-api","title":"Interacting with the Translation API","text":""},{"location":"blog/huggingface/trans/#translating-text","title":"Translating Text","text":"
Translate text from one language to another using a simple HTTP request.
For use cases requiring specific translation strategies or parameters (e.g., beam search, number of beams), you can pass additional parameters in your request to customize the translation process.
"},{"location":"blog/huggingface/trans/#use-cases-variations","title":"Use Cases & Variations","text":""},{"location":"blog/huggingface/trans/#different-language-pairs","title":"Different Language Pairs","text":"
Adjust the source_lang and target_lang parameters to cater to various language pairs, enabling translation between numerous languages supported by the chosen model.
There are two families of models from facebook that can perform any to any language translation among a large number of languages.
facebook/mbart-large-50-many-to-many-mmt: 50 languages
facebook/nllb-200-distilled-600M: 200 languages
Both the MBART and the NLLB families have several members, with facebook/nllb-moe-54b 54billion parameter mixture of experts being the largest and most capable one.
See here for the language codes for the FLORES-200 dataset.
Now how do we even verify whether this is correct? Lets reverse translate followed by sentence similarity from NLI. We need to launch 2 containers - one for translation and another for NLI:
import requests\n# First we translate this hindi sentence to tatar\ndata = {\n\"text\": \"\u0938\u0902\u092f\u0941\u0915\u094d\u0924 \u0930\u093e\u0937\u094d\u091f\u094d\u0930 \u0915\u0947 \u092a\u094d\u0930\u092e\u0941\u0916 \u0915\u093e \u0915\u0939\u0928\u093e \u0939\u0948 \u0915\u093f \u0938\u0940\u0930\u093f\u092f\u093e \u092e\u0947\u0902 \u0915\u094b\u0908 \u0938\u0948\u0928\u094d\u092f \u0938\u092e\u093e\u0927\u093e\u0928 \u0928\u0939\u0940\u0902 \u0939\u0948\",\n\"target_lang\": \"tat_Cyrl\",\n\"decoding_strategy\": \"generate\",\n\"bos_token_id\": 0,\n\"decoder_start_token_id\": 2,\n\"eos_token_id\": 2,\n\"max_length\": 200,\n\"pad_token_id\": 1\n}\nresponse = requests.post(\"http://localhost:3000/api/v1/translate\",\njson=data,\nauth=('user', 'password'))\ntranslated = response.json()[\"translated_text\"]\n# \u0411\u041c\u041e \u0431\u0430\u0448\u043b\u044b\u0433\u044b \u0421\u04af\u0440\u0438\u044f\u0434\u04d9 \u0445\u04d9\u0440\u0431\u0438 \u0447\u0430\u0440\u0430\u043b\u0430\u0440 \u044e\u043a \u0434\u0438\u043f \u0431\u0435\u043b\u0434\u0435\u0440\u04d9\n# Then we translate the tatar back to hindi\nrev = data.copy()\nrev[\"text\"] = translated\nrev[\"target_lang\"] = \"hin_Deva\"\nresponse = requests.post(\"http://localhost:3000/api/v1/translate\",\njson=rev,\nauth=('user', 'password'))\nrev_translated = response.json()[\"translated_text\"]\n# Finally we look at similarity of the source and reverse-translated hindi sentences\ndata = {\n\"text1\": data[\"text\"],\n\"text2\": rev_translated\n}\nresponse = requests.post(\"http://localhost:3001/api/v1/textual_similarity\",\njson=data,\nauth=('user', 'password'))\nprint(response.json())\n# {\n# 'text1': '\u0938\u0902\u092f\u0941\u0915\u094d\u0924 \u0930\u093e\u0937\u094d\u091f\u094d\u0930 \u0915\u0947 \u092a\u094d\u0930\u092e\u0941\u0916 \u0915\u093e \u0915\u0939\u0928\u093e \u0939\u0948 \u0915\u093f \u0938\u0940\u0930\u093f\u092f\u093e \u092e\u0947\u0902 \u0915\u094b\u0908 \u0938\u0948\u0928\u094d\u092f \u0938\u092e\u093e\u0927\u093e\u0928 \u0928\u0939\u0940\u0902 \u0939\u0948',\n# 'text2': '\u092c\u0940\u090f\u092e\u0913 \u092a\u094d\u0930\u092e\u0941\u0916 \u0928\u0947 \u0915\u0939\u093e \u0915\u093f \u0938\u0940\u0930\u093f\u092f\u093e \u092e\u0947\u0902 \u0915\u094b\u0908 \u0938\u0948\u0928\u094d\u092f \u0909\u092a\u093e\u092f \u0928\u0939\u0940\u0902 \u0939\u0948\u0902',\n# 'similarity_score': 0.9829527983379287\n# }\n
0.9829527983379287 looks like a great similarity score, so the translation really works! (or the mistakes are isomorphic) \ud83e\udd73\ud83d\udc4d"},{"location":"blog/huggingface/trans/#play-around","title":"Play around","text":"
There is not much to really do in translation except mess around with different languagues \ud83e\udd37\u200d\u2642\ufe0f Not many models either, facebook is the undisputed leader in translation models.
"},{"location":"blog/huggingface/txtclass/","title":"Host Text Classification Models Using Geniusrise","text":"
Host Text Classification Models Using Geniusrise
Quick Setup
Configuration Breakdown
Use Cases \\& Variations
Sentiment Analysis
Content Moderation
Language Detection
Making API Requests
Classify Text
Classification Pipeline
Fun
Political bias detection
Intent classification
Hallucination Evaluation
Irony Detection
Play around
This post will guide you through creating inference APIs for different text classification tasks using geniusrise, explaining the genius.yml configuration and providing examples of how to interact with your API using curl and python-requests.
For detecting the language of the input text, a model like xlm-roberta-base is suitable.
args:\n model_name: \"xlm-roberta-base\"\n
Try out various models from huggingface.
"},{"location":"blog/huggingface/txtclass/#making-api-requests","title":"Making API Requests","text":""},{"location":"blog/huggingface/txtclass/#classify-text","title":"Classify Text","text":"
cURL:
curl -X POST http://localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\"text\": \"Your text here.\"}'\n
Python-Requests:
import requests\nresponse = requests.post(\"http://localhost:3000/api/v1/classify\",\njson={\"text\": \"Your text here.\"},\nauth=('user', 'password'))\nprint(response.json())\n
/usr/bin/curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"i think i agree with bjp that hindus need to be respected\"\n }' | jq\n\n# {\n# \"input\": \"i think i agree with bjp that hindus need to be respected\",\n# \"label_scores\": {\n# \"LEFT\": 0.28080788254737854,\n# \"CENTER\": 0.18140915036201477,\n# \"RIGHT\": 0.5377829670906067 # <--\n# }\n# }\n
/usr/bin/curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"these ghettos are sprawling these days and the people who live there stink\"\n }' | jq\n\n# {\n# \"input\": \"these ghettos are sprawling these days and the people who live there stink\",\n# \"label_scores\": {\n# \"LEFT\": 0.38681042194366455, # <-- NIMBY?\n# \"CENTER\": 0.20437702536582947,\n# \"RIGHT\": 0.408812552690506 # <--\n# }\n# }\n
Works fairly well empirically for medium-sized sentences and in an american context.
Text classification can be used to figure out the intent of the user in a chat conversation scenario. For e.g. to determine whether the user has an intent to explore or to buy.
/usr/bin/curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"A man walks into a bar and buys a drink [SEP] A bloke swigs alcohol at a pub\"\n }' | jq\n\n# {\n# \"input\": \"A man walks into a bar and buys a drink [SEP] A bloke swigs alcohol at a pub\",\n# \"label_scores\": [\n# 0.6105160713195801\n# ]\n# }\n
/usr/bin/curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-u \"user:password\" \\\n-d '{\n \"text\": \"What a wonderful day to have a flat tire!\"\n }' | jq\n\n# {\n# \"input\": \"What a wonderful day to have a flat tire!\",\n# \"label_scores\": {\n# \"non_irony\": 0.023495545610785484,\n# \"irony\": 0.9765045046806335 <---\n# }\n# }\n
There are 49,863 text classification models as of this article on huggingface. Play around with them, tweak various parameters, learn about various usecases and cool shit that can be built with \"mere\" text classification!
"},{"location":"blog/huggingface/vqa/","title":"Host Visual QA Models Using Geniusrise","text":"
Visual Question Answering (VQA) combines the power of visual understanding with natural language processing to answer questions about images. Geniusrise offers a streamlined process to deploy VQA models as APIs, making it accessible to developers to integrate advanced AI capabilities into their applications. This blog post demonstrates how to set up VQA APIs using Geniusrise and provides examples for various use cases.
Create a genius.yml configuration file tailored to your API requirements, specifying the model, tokenizer, and additional parameters necessary for inference.
This configuration sets up a VQA API using the Pix2Struct model, ready to process images and answer questions about them.
"},{"location":"blog/huggingface/vqa/#interacting-with-your-api","title":"Interacting with Your API","text":"
To interact with your VQA API, encode your images in base64 format and construct a JSON payload with the image and the question. Here are examples using curl:
# Convert the image to base64 and prepare the payload\nbase64 -w 0 image.jpg | awk '{print \"{\\\"image_base64\\\": \\\"\"$0\"\\\", \\\"question\\\": \\\"What is in this image?\\\"}\"}' > payload.json\n\n# Send the request to your API\ncurl -X POST http://localhost:3000/api/v1/answer_question \\\n-H \"Content-Type: application/json\" \\\n-u user:password \\\n-d @payload.json | jq\n
For specialized domains, such as medical imaging or technical diagrams, tailor your genius.yml to use domain-specific models. This requires replacing the model_name, model_class, and processor_class with those suitable for your specific application.
Experiment with different models, precision levels, and CUDA settings to optimize performance and accuracy for your use case. Geniusrise allows for detailed configuration, including quantization and torchscript options, to fine-tune the deployment according to your requirements.
"},{"location":"bolts/openai/base/","title":"Base Fine Tuner","text":"
Bases: Bolt
An abstract base class for writing bolts for fine-tuning OpenAI models.
This base class is intended to be subclassed for fine-tuning OpenAI models. The chief objective of its subclasses is to load and preprocess the dataset, though of course, other methods, including fine-tuning, can be overridden for customization.
This bolt uses the OpenAI API to fine-tune a pre-trained model.
Each subclass can be invoked using the genius cli or yaml.
Name Type Description DatasetUnion[Dataset, DatasetDict, Optional[Dataset]]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/classification/#geniusrise_openai.classification.OpenAIClassificationFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/classification/#geniusrise_openai.classification.OpenAIClassificationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"label\": \"The label\"}\n
Load a commonsense reasoning dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required **kwargsAny
Additional keyword arguments.
{}
Returns:
Name Type Description DatasetUnion[Dataset, DatasetDict, Optional[Dataset]]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/commonsense_reasoning/#geniusrise_openai.commonsense_reasoning.OpenAICommonsenseReasoningFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/commonsense_reasoning/#geniusrise_openai.commonsense_reasoning.OpenAICommonsenseReasoningFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Load an instruction following dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required **kwargsAny
Additional keyword arguments.
{}
Returns:
Name Type Description DatasetUnion[Dataset, DatasetDict, Optional[Dataset]]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/instruction_tuning/#geniusrise_openai.instruction_tuning.OpenAIInstructionFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/instruction_tuning/#geniusrise_openai.instruction_tuning.OpenAIInstructionFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Load a language modeling dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required
Returns:
Name Type Description DatasetUnion[Dataset, DatasetDict, Optional[Dataset]]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/language_model/#geniusrise_openai.language_model.OpenAILanguageModelFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/language_model/#geniusrise_openai.language_model.OpenAILanguageModelFineTuner.load_dataset--dataset-files-saved-by-hugging-face-datasets-library","title":"Dataset files saved by Hugging Face datasets library","text":"
The directory should contain 'dataset_info.json' and other related files.
Load a language modeling dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required maskedbool
Whether to use masked language modeling. Defaults to True.
required max_lengthint
The maximum length for tokenization. Defaults to 512.
required
Returns:
Name Type Description DatasetNone
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/language_model/#geniusrise_openai.language_model.OpenAILanguageModelFineTuner.prepare_fine_tuning_data--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/language_model/#geniusrise_openai.language_model.OpenAILanguageModelFineTuner.prepare_fine_tuning_data--dataset-files-saved-by-hugging-face-datasets-library","title":"Dataset files saved by Hugging Face datasets library","text":"
The directory should contain 'dataset_info.json' and other related files.
Load a named entity recognition dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required
Returns:
Name Type Description DatasetDictUnion[Dataset, DatasetDict, None]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"bolts/openai/ner/#geniusrise_openai.ner.NamedEntityRecognitionFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/ner/#geniusrise_openai.ner.NamedEntityRecognitionFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
"},{"location":"bolts/openai/question_answering/#geniusrise_openai.question_answering.OpenAIQuestionAnsweringFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/question_answering/#geniusrise_openai.question_answering.OpenAIQuestionAnsweringFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
Type Description Union[Dataset, DatasetDict, Optional[Dataset]]
Dataset | DatasetDict: The loaded dataset.
"},{"location":"bolts/openai/sentiment_analysis/#geniusrise_openai.sentiment_analysis.OpenAISentimentAnalysisFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/sentiment_analysis/#geniusrise_openai.sentiment_analysis.OpenAISentimentAnalysisFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"label\": \"The label\"}\n
"},{"location":"bolts/openai/summarization/#geniusrise_openai.summarization.OpenAISummarizationFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"bolts/openai/summarization/#geniusrise_openai.summarization.OpenAISummarizationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"summary\": \"The summary\"}\n
"},{"location":"bolts/openai/translation/#geniusrise_openai.translation.OpenAITranslationFineTuner.load_dataset--supported-data-formats-and-structures-for-translation-tasks","title":"Supported Data Formats and Structures for Translation Tasks:","text":""},{"location":"bolts/openai/translation/#geniusrise_openai.translation.OpenAITranslationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
AirflowRunner is a utility for managing and orchestrating Airflow DAGs. It is designed to provide a command-line interface (CLI) for creating, describing, showing, deleting, and getting the status of Airflow DAGs.
This class uses the Airflow models to interact with DAGs and DockerOperator to run tasks in Docker containers. It is aimed to simplify the deployment and management of Airflow tasks, providing a straightforward way to deploy DAGs with Docker tasks from the command line.
CLI Usage
genius airflow sub-command
Sub-commands
create: Create a new DAG with the given parameters and Docker task. genius airflow create [options]
describe: Describe a specific DAG by its ID. genius airflow describe --dag_id example_dag
show: Show all available DAGs in the Airflow environment. genius airflow show
delete: Delete a specific DAG by its ID. genius airflow delete --dag_id example_dag
status: Get the status of a specific DAG by its ID. genius airflow status --dag_id example_dag --airflow_api_base_url http://localhost:8080/api/v1
Each sub-command supports various options to specify the details of the DAG or the Docker task, such as the schedule interval, start date, owner, image, command, and more.
Additional keyword arguments for initializing the spout.
Keyword Arguments:\n Batch input:\n - input_folder (str): The input folder argument.\n - input_s3_bucket (str): The input bucket argument.\n - input_s3_folder (str): The input S3 folder argument.\n Batch outupt:\n - output_folder (str): The output folder argument.\n - output_s3_bucket (str): The output bucket argument.\n - output_s3_folder (str): The output S3 folder argument.\n Streaming input:\n - input_kafka_cluster_connection_string (str): The input Kafka servers argument.\n - input_kafka_topic (str): The input kafka topic argument.\n - input_kafka_consumer_group_id (str): The Kafka consumer group id.\n Streaming output:\n - output_kafka_cluster_connection_string (str): The output Kafka servers argument.\n - output_kafka_topic (str): The output kafka topic argument.\n Redis state manager config:\n - redis_host (str): The host address for the Redis server.\n - redis_port (int): The port number for the Redis server.\n - redis_db (int): The Redis database to be used.\n Postgres state manager config:\n - postgres_host (str): The host address for the PostgreSQL server.\n - postgres_port (int): The port number for the PostgreSQL server.\n - postgres_user (str): The username for the PostgreSQL server.\n - postgres_password (str): The password for the PostgreSQL server.\n - postgres_database (str): The PostgreSQL database to be used.\n - postgres_table (str): The PostgreSQL table to be used.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The name of the DynamoDB table.\n - dynamodb_region_name (str): The AWS region for DynamoDB.\n Deployment\n - k8s_kind (str): Kind opf kubernetes resource to be deployed as, choices are \"deployment\", \"service\", \"job\", \"cron_job\"\n - k8s_name (str): Name of the Kubernetes resource.\n - k8s_image (str): Docker image for the Kubernetes resource.\n - k8s_replicas (int): Number of replicas.\n - k8s_env_vars (json): Environment variables as a JSON string.\n - k8s_cpu (str): CPU requirements.\n - k8s_memory (str): Memory requirements.\n - k8s_storage (str): Storage requirements.\n - k8s_gpu (str): GPU requirements.\n - k8s_kube_config_path (str): Name of the Kubernetes cluster local config.\n - k8s_api_key (str): GPU requirements.\n - k8s_api_host (str): GPU requirements.\n - k8s_verify_ssl (str): GPU requirements.\n - k8s_ssl_ca_cert (str): GPU requirements.\n - k8s_cluster_name (str): Name of the Kubernetes cluster.\n - k8s_context_name (str): Name of the kubeconfig context.\n - k8s_namespace (str): Kubernetes namespace.\", default=\"default\n - k8s_labels (json): Labels for Kubernetes resources, as a JSON string.\n - k8s_annotations (json): Annotations for Kubernetes resources, as a JSON string.\n - k8s_port (int): Port to run the spout on as a service.\n - k8s_target_port (int): Port to expose the spout on as a service.\n - k8s_schedule (str): Schedule to run the spout on as a cron job.\n
The type of state manager (\"none\", \"redis\", \"postgres\", or \"dynamodb\").
required **kwargs
Additional keyword arguments for initializing the spout.
Keyword Arguments:\n Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n Streaming output:\n - output_kafka_topic (str): Kafka output topic for streaming spouts.\n - output_kafka_cluster_connection_string (str): Kafka connection string for streaming spouts.\n Stream to Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n - buffer_size (int): Number of messages to buffer.\n Redis state manager config:\n - redis_host (str): The host address for the Redis server.\n - redis_port (int): The port number for the Redis server.\n - redis_db (int): The Redis database to be used.\n Postgres state manager config:\n - postgres_host (str): The host address for the PostgreSQL server.\n - postgres_port (int): The port number for the PostgreSQL server.\n - postgres_user (str): The username for the PostgreSQL server.\n - postgres_password (str): The password for the PostgreSQL server.\n - postgres_database (str): The PostgreSQL database to be used.\n - postgres_table (str): The PostgreSQL table to be used.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The name of the DynamoDB table.\n - dynamodb_region_name (str): The AWS region for DynamoDB.\n
Additional keyword arguments for initializing the spout.
Keyword Arguments:\n Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n Streaming output:\n - output_kafka_topic (str): Kafka output topic for streaming spouts.\n - output_kafka_cluster_connection_string (str): Kafka connection string for streaming spouts.\n Stream to Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n - buffer_size (int): Number of messages to buffer.\n Redis state manager config:\n - redis_host (str): The host address for the Redis server.\n - redis_port (int): The port number for the Redis server.\n - redis_db (int): The Redis database to be used.\n Postgres state manager config:\n - postgres_host (str): The host address for the PostgreSQL server.\n - postgres_port (int): The port number for the PostgreSQL server.\n - postgres_user (str): The username for the PostgreSQL server.\n - postgres_password (str): The password for the PostgreSQL server.\n - postgres_database (str): The PostgreSQL database to be used.\n - postgres_table (str): The PostgreSQL table to be used.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The name of the DynamoDB table.\n - dynamodb_region_name (str): The AWS region for DynamoDB.\n Deployment\n - k8s_kind (str): Kind opf kubernetes resource to be deployed as, choices are \"deployment\", \"service\", \"job\", \"cron_job\"\n - k8s_name (str): Name of the Kubernetes resource.\n - k8s_image (str): Docker image for the Kubernetes resource.\n - k8s_replicas (int): Number of replicas.\n - k8s_env_vars (json): Environment variables as a JSON string.\n - k8s_cpu (str): CPU requirements.\n - k8s_memory (str): Memory requirements.\n - k8s_storage (str): Storage requirements.\n - k8s_gpu (str): GPU requirements.\n - k8s_kube_config_path (str): Name of the Kubernetes cluster local config.\n - k8s_api_key (str): GPU requirements.\n - k8s_api_host (str): GPU requirements.\n - k8s_verify_ssl (str): GPU requirements.\n - k8s_ssl_ca_cert (str): GPU requirements.\n - k8s_cluster_name (str): Name of the Kubernetes cluster.\n - k8s_context_name (str): Name of the kubeconfig context.\n - k8s_namespace (str): Kubernetes namespace.\", default=\"default\n - k8s_labels (json): Labels for Kubernetes resources, as a JSON string.\n - k8s_annotations (json): Annotations for Kubernetes resources, as a JSON string.\n - k8s_port (int): Port to run the spout on as a service.\n - k8s_target_port (int): Port to expose the spout on as a service.\n - k8s_schedule (str): Schedule to run the spout on as a cron job.\n
Command-line interface for managing spouts and bolts based on a YAML configuration.
The YamlCtl class provides methods to run specific or all spouts and bolts defined in a YAML file. The YAML file's structure is defined by the Geniusfile schema.
Run the command-line interface for managing spouts and bolts based on provided arguments. Please note that there is no ordering of the spouts and bolts in the YAML configuration. Each spout and bolt is an independent entity even when connected together.
Parameters:
Name Type Description Default argsargparse.Namespace
The Bolt class is a base class for all bolts in the given context. It inherits from the Task class and provides methods for executing tasks both locally and remotely, as well as managing their state, with state management options including in-memory, Redis, PostgreSQL, and DynamoDB, and input and output data for batch, streaming, stream-to-batch, and batch-to-streaming.
The Bolt class uses the Input, Output and State classes, which are abstract base classes for managing input data, output data and states, respectively. The Input and Output classes each have two subclasses: StreamingInput, BatchInput, StreamingOutput and BatchOutput, which manage streaming and batch input and output data, respectively. The State class is used to get and set state, and it has several subclasses for different types of state managers.
The Bolt class also uses the ECSManager and K8sManager classes in the execute_remote method, which are used to manage tasks on Amazon ECS and Kubernetes, respectively.
Usage
Create an instance of the Bolt class by providing an Input object, an Output object and a State object.
The Input object specifies the input data for the bolt.
The Output object specifies the output data for the bolt.
The State object handles the management of the bolt's state.
This static method is used to create a bolt of a specific type. It takes in an input type, an output type, a state type, and additional keyword arguments for initializing the bolt.
The method creates the input, output, and state manager based on the provided types, and then creates and returns a bolt using these configurations.
Parameters:
Name Type Description Default klasstype
The Bolt class to create.
required input_typestr
The type of input (\"batch\" or \"streaming\").
required output_typestr
The type of output (\"batch\" or \"streaming\").
required state_typestr
The type of state manager (\"none\", \"redis\", \"postgres\", or \"dynamodb\").
required **kwargs
Additional keyword arguments for initializing the bolt.
Keyword Arguments:\n Batch input:\n - input_folder (str): The input folder argument.\n - input_s3_bucket (str): The input bucket argument.\n - input_s3_folder (str): The input S3 folder argument.\n Batch output config:\n - output_folder (str): The output folder argument.\n - output_s3_bucket (str): The output bucket argument.\n - output_s3_folder (str): The output S3 folder argument.\n Streaming input:\n - input_kafka_cluster_connection_string (str): The input Kafka servers argument.\n - input_kafka_topic (str): The input kafka topic argument.\n - input_kafka_consumer_group_id (str): The Kafka consumer group id.\n Streaming output:\n - output_kafka_cluster_connection_string (str): The output Kafka servers argument.\n - output_kafka_topic (str): The output kafka topic argument.\n Stream-to-Batch input:\n - buffer_size (int): Number of messages to buffer.\n - input_kafka_cluster_connection_string (str): The input Kafka servers argument.\n - input_kafka_topic (str): The input kafka topic argument.\n - input_kafka_consumer_group_id (str): The Kafka consumer group id.\n Batch-to-Streaming input:\n - buffer_size (int): Number of messages to buffer.\n - input_folder (str): The input folder argument.\n - input_s3_bucket (str): The input bucket argument.\n - input_s3_folder (str): The input S3 folder argument.\n Stream-to-Batch output:\n - buffer_size (int): Number of messages to buffer.\n - output_folder (str): The output folder argument.\n - output_s3_bucket (str): The output bucket argument.\n - output_s3_folder (str): The output S3 folder argument.\n Redis state manager config:\n - redis_host (str): The Redis host argument.\n - redis_port (str): The Redis port argument.\n - redis_db (str): The Redis database argument.\n Postgres state manager config:\n - postgres_host (str): The PostgreSQL host argument.\n - postgres_port (str): The PostgreSQL port argument.\n - postgres_user (str): The PostgreSQL user argument.\n - postgres_password (str): The PostgreSQL password argument.\n - postgres_database (str): The PostgreSQL database argument.\n - postgres_table (str): The PostgreSQL table argument.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The DynamoDB table name argument.\n - dynamodb_region_name (str): The DynamoDB region name argument.\n
{}
Returns:
Name Type Description BoltBolt
The created bolt.
Raises:
Type Description ValueError
If an invalid input type, output type, or state type is provided.
"},{"location":"core/core_data_batch_input/","title":"Batch data input","text":"
"},{"location":"core/core_data_batch_input/#core.data.batch_input.BatchInput--get-the-input-folder","title":"Get the input folder","text":"
folder = input.get()\n
"},{"location":"core/core_data_batch_input/#core.data.batch_input.BatchInput--save-a-spark-dataframe-to-the-input-folder","title":"Save a Spark DataFrame to the input folder","text":"
"},{"location":"core/core_data_batch_input/#core.data.batch_input.BatchInput--copy-files-from-s3-to-the-input-folder","title":"Copy files from S3 to the input folder","text":"
Consume messages from a Kafka topic and save them as JSON files in the input folder. Stops consuming after reaching the latest message or the specified number of messages.
Parameters:
Name Type Description Default input_topicstr
Kafka topic to consume data from.
required kafka_cluster_connection_stringstr
Connection string for the Kafka cluster.
required nr_messagesint
Number of messages to consume. Defaults to 1000.
1000group_idstr
Kafka consumer group ID. Defaults to \"geniusrise\".
'geniusrise'partition_schemeOptional[str]
Optional partitioning scheme for Kafka, e.g., \"year/month/day\".
None
Returns:
Name Type Description strstr
The path to the folder where the consumed messages are saved as JSON files.
Partitioning scheme for S3, e.g., \"year/month/day\".
Raises:
Type Description FileNotExistError
If the output folder does not exist.
Parameters:
Name Type Description Default output_folderstr
Folder to save output files.
required bucketstr
S3 bucket name.
required s3_folderstr
Folder within the S3 bucket.
required partition_schemeOptional[str]
Partitioning scheme for S3, e.g., \"year/month/day\".
None Usage
# Initialize the BatchOutput instance\nconfig = BatchOutput(\"/path/to/output\", \"my_bucket\", \"s3/folder\", partition_scheme=\"%Y/%m/%d\")\n# Save data to a file\nconfig.save({\"key\": \"value\"}, \"example.json\")\n# Compose multiple BatchOutput instances\nresult = config1.compose(config2, config3)\n# Convert output to a Spark DataFrame\nspark_df = config.to_spark(spark_session)\n# Copy files to a remote S3 bucket\nconfig.to_s3()\n# Flush the output to S3\nconfig.flush()\n# Collect metrics\nmetrics = config.collect_metrics()\n
\ud83d\udce1 StreamingInput: Manages streaming input data from Kafka and other streaming sources.
Attributes:
Name Type Description input_topicstr
Kafka topic to consume data from.
kafka_cluster_connection_stringstr
Connection string for the Kafka cluster.
group_idstr
Kafka consumer group ID.
consumerKafkaConsumer
Kafka consumer instance.
Usage
input = StreamingInput(\"my_topic\", \"localhost:9094\") for message in input.get(): print(message.value)
Parameters:
Name Type Description Default input_topicstr
Kafka topic to consume data from.
required kafka_cluster_connection_stringstr
Connection string for the Kafka cluster.
required group_idstr
Kafka consumer group ID. Defaults to \"geniusrise\".
'geniusrise'**kwargs
Additional keyword arguments for KafkaConsumer.
{}
Raises:
Type Description KafkaConnectionError
If unable to connect to Kafka.
Usage"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-get-method-to-consume-from-kafka","title":"Using get method to consume from Kafka","text":"
input = StreamingInput(\"my_topic\", \"localhost:9094\")\nconsumer = input.get()\nfor message in consumer:\nprint(message.value)\n
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-from_streamz-method-to-process-streamz-dataframe","title":"Using from_streamz method to process streamz DataFrame","text":"
input = StreamingInput(\"my_topic\", \"localhost:9094\")\nstreamz_df = ... # Assume this is a streamz DataFrame\nfor row in input.from_streamz(streamz_df):\nprint(row)\n
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-from_spark-method-to-process-spark-dataframe","title":"Using from_spark method to process Spark DataFrame","text":"
input = StreamingInput(\"my_topic\", \"localhost:9094\")\nspark_df = ... # Assume this is a Spark DataFrame\nmap_func = lambda row: {\"key\": row.key, \"value\": row.value}\nquery_or_rdd = input.from_spark(spark_df, map_func)\n
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-compose-method-to-merge-multiple-streaminginput-instances","title":"Using compose method to merge multiple StreamingInput instances","text":"
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-close-method-to-close-the-kafka-consumer","title":"Using close method to close the Kafka consumer","text":"
"},{"location":"core/core_data_streaming_input/#core.data.streaming_input.StreamingInput--using-seek-method-to-seek-to-a-specific-offset","title":"Using seek method to seek to a specific offset","text":"
The Spout class is a base class for all spouts in the given context. It inherits from the Task class and provides methods for executing tasks both locally and remotely, as well as managing their state, with state management options including in-memory, Redis, PostgreSQL, and DynamoDB, and output data for batch or streaming data.
The Spout class uses the Output and State classes, which are abstract base classes for managing output data and states, respectively. The Output class has two subclasses: StreamingOutput and BatchOutput, which manage streaming and batch output data, respectively. The State class is used to get and set state, and it has several subclasses for different types of state managers.
The Spout class also uses the ECSManager and K8sManager classes in the execute_remote method, which are used to manage tasks on Amazon ECS and Kubernetes, respectively.
Usage
Create an instance of the Spout class by providing an Output object and a State object.
The Output object specifies the output data for the spout.
The State object handles the management of the spout's state.
Example
output = Output(...) state = State(...) spout = Spout(output, state)
The type of state manager (\"none\", \"redis\", \"postgres\", or \"dynamodb\").
required **kwargs
Additional keyword arguments for initializing the spout.
Keyword Arguments:\n Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n Streaming output:\n - output_kafka_topic (str): Kafka output topic for streaming spouts.\n - output_kafka_cluster_connection_string (str): Kafka connection string for streaming spouts.\n Stream to Batch output:\n - output_folder (str): The directory where output files should be stored temporarily.\n - output_s3_bucket (str): The name of the S3 bucket for output storage.\n - output_s3_folder (str): The S3 folder for output storage.\n - buffer_size (int): Number of messages to buffer.\n Redis state manager config:\n - redis_host (str): The host address for the Redis server.\n - redis_port (int): The port number for the Redis server.\n - redis_db (int): The Redis database to be used.\n Postgres state manager config:\n - postgres_host (str): The host address for the PostgreSQL server.\n - postgres_port (int): The port number for the PostgreSQL server.\n - postgres_user (str): The username for the PostgreSQL server.\n - postgres_password (str): The password for the PostgreSQL server.\n - postgres_database (str): The PostgreSQL database to be used.\n - postgres_table (str): The PostgreSQL table to be used.\n DynamoDB state manager config:\n - dynamodb_table_name (str): The name of the DynamoDB table.\n - dynamodb_region_name (str): The AWS region for DynamoDB\n
{}
Returns:
Name Type Description SpoutSpout
The created spout.
Raises:
Type Description ValueError
If an invalid output type or state type is provided.
\ud83d\udee0\ufe0f Task: Class for managing tasks.
This class provides a foundation for creating and managing tasks. Each task has a unique identifier and can be associated with specific input and output data.
\ud83d\udda8\ufe0f Pretty print the fetch_* methods and their parameters along with their default values and docstrings. Also prints the class's docstring and init parameters.
DockerResourceManager is a utility for managing Docker resources, including containers and images. It provides a command-line interface (CLI) for various Docker operations, such as listing, inspecting, creating, starting, and stopping containers, as well as managing images.
This class uses the Docker SDK for Python to interact with the Docker daemon, offering a convenient way to manage Docker containers and images from the command line.
CLI Usage
genius docker sub-command
Sub-commands
list_containers: List all containers, with an option to include stopped containers. genius docker list_containers [--all]
inspect_container: Inspect a specific container by its ID. genius docker inspect_container <container_id>
create_container: Create a new container with specified image, command, and other parameters. genius docker create_container <image> [options]
start_container: Start a container by its ID. genius docker start_container <container_id>
stop_container: Stop a container by its ID. genius docker stop_container <container_id>
list_images: List all Docker images available on the local system. genius docker list_images
inspect_image: Inspect a specific image by its ID. genius docker inspect_image <image_id>
pull_image: Pull an image from a Docker registry. genius docker pull_image <image>
push_image: Push an image to a Docker registry. genius docker push_image <image>
Each sub-command supports various options to specify the details of the container or image operation, such as environment variables, port mappings, volume mappings, and more.
Attributes:
Name Type Description client
The Docker client connection to interact with the Docker daemon.
log
Logger for the class to log information, warnings, and errors.
console
Rich console object to print formatted and styled outputs.
Methods
connect: Method to establish a connection to the Docker daemon.
list_containers: Method to list all containers, with an option to include stopped ones.
inspect_container: Method to inspect details of a specific container.
create_container: Method to create a new container with given parameters.
start_container: Method to start a specific container.
stop_container: Method to stop a specific container.
list_images: Method to list all Docker images.
inspect_image: Method to inspect a specific image.
pull_image: Method to pull an image from a Docker registry.
push_image: Method to push an image to a Docker registry.
Note
Ensure that the Docker daemon is running and accessible at the specified URL.
Make sure to have the necessary permissions to interact with the Docker daemon and manage containers and images.
DockerSwarmManager is a utility for managing Docker Swarm services, including creating, inspecting, updating, and removing services. It extends DockerResourceManager to provide swarm-specific functionalities and commands via a command-line interface (CLI).
The manager interacts with the Docker Swarm API, offering a convenient way to manage Swarm services, nodes, and other swarm-related tasks from the command line.
CLI Usage
genius docker swarm sub-command
Sub-commands
list_nodes: List all nodes in the Docker Swarm. genius docker swarm list_nodes
inspect_node: Inspect a specific Swarm node by its ID. genius docker swarm inspect_node <node_id>
create_service: Create a new service in the Docker Swarm with comprehensive specifications. genius docker swarm create_service [options]
list_services: List all services in the Docker Swarm. genius docker swarm list_services
inspect_service: Inspect a specific service by its ID. genius docker swarm inspect_service <service_id>
update_service: Update an existing service with new parameters. genius docker swarm update_service <service_id> [options]
remove_service: Remove a service from the Docker Swarm. genius docker swarm remove_service <service_id>
service_logs: Retrieve logs of a Docker Swarm service. genius docker swarm service_logs <service_id> [--tail] [--follow]
scale_service: Scale a service to a specified number of replicas. genius docker swarm scale_service <service_id> <replicas>
Each sub-command supports various options to specify the details of the swarm node or service operation. These options include node and service IDs, image and command specifications for services, environment variables, resource limits, and much more.
Attributes:
Name Type Description swarm_client
The Docker Swarm client connection to interact with the Docker Swarm API.
log
Logger for the class to log information, warnings, and errors.
console
Rich console object to print formatted and styled outputs.
Methods
connect_to_swarm: Method to establish a connection to the Docker Swarm.
list_nodes: Method to list all nodes in the Docker Swarm.
inspect_node: Method to inspect details of a specific Swarm node.
create_service: Method to create a new service with given specifications.
list_services: Method to list all services in the Docker Swarm.
inspect_service: Method to inspect a specific service.
update_service: Method to update an existing service with new parameters.
remove_service: Method to remove a service from the Docker Swarm.
get_service_logs: Method to retrieve logs of a Docker Swarm service.
scale_service: Method to scale a service to a specified number of replicas.
Note
Ensure that the Docker Swarm is initialized and running.
Make sure to have the necessary permissions to interact with the Docker Swarm and manage services and nodes.
\ud83d\ude80 The CronJob class is responsible for managing Kubernetes CronJobs. It extends the Job class and provides additional functionalities specific to Kubernetes CronJobs.
\ud83d\ude80 The Job class is responsible for managing Kubernetes Jobs. It extends the Deployment class and provides additional functionalities specific to Kubernetes Jobs.
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/arangodb/#geniusrise_databases.arangodb.ArangoDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/arangodb/#geniusrise_databases.arangodb.ArangoDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/athena/#geniusrise_databases.athena.Athena.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/athena/#geniusrise_databases.athena.Athena.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/azure_table/#geniusrise_databases.azure_table.AzureTableStorage.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/azure_table/#geniusrise_databases.azure_table.AzureTableStorage.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/bigquery/#geniusrise_databases.bigquery.BigQuery.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/bigquery/#geniusrise_databases.bigquery.BigQuery.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/bigtable/#geniusrise_databases.bigtable.Bigtable.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/bigtable/#geniusrise_databases.bigtable.Bigtable.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/cassandra/#geniusrise_databases.cassandra.Cassandra.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/cassandra/#geniusrise_databases.cassandra.Cassandra.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/cloud_sql/#geniusrise_databases.cloud_sql.GoogleCloudSQL.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/cloud_sql/#geniusrise_databases.cloud_sql.GoogleCloudSQL.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/cockroach/#geniusrise_databases.cockroach.CockroachDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/cockroach/#geniusrise_databases.cockroach.CockroachDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/cosmosdb/#geniusrise_databases.cosmosdb.CosmosDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/cosmosdb/#geniusrise_databases.cosmosdb.CosmosDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/couchbase/#geniusrise_databases.couchbase.Couchbase.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/couchbase/#geniusrise_databases.couchbase.Couchbase.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/db2/#geniusrise_databases.db2.DB2.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/db2/#geniusrise_databases.db2.DB2.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/documentdb/#geniusrise_databases.documentdb.DocumentDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/documentdb/#geniusrise_databases.documentdb.DocumentDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/dynamodb/#geniusrise_databases.dynamodb.DynamoDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/dynamodb/#geniusrise_databases.dynamodb.DynamoDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/elasticsearch/#geniusrise_databases.elasticsearch.Elasticsearch.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/elasticsearch/#geniusrise_databases.elasticsearch.Elasticsearch.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/firestore/#geniusrise_databases.firestore.Firestore.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/firestore/#geniusrise_databases.firestore.Firestore.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/graphite/#geniusrise_databases.graphite.Graphite.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/graphite/#geniusrise_databases.graphite.Graphite.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/hbase/#geniusrise_databases.hbase.HBase.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/hbase/#geniusrise_databases.hbase.HBase.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/influxdb/#geniusrise_databases.influxdb.InfluxDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/influxdb/#geniusrise_databases.influxdb.InfluxDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/kairosdb/#geniusrise_databases.kairosdb.KairosDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/kairosdb/#geniusrise_databases.kairosdb.KairosDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/keyspaces/#geniusrise_databases.keyspaces.AWSKeyspaces.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/keyspaces/#geniusrise_databases.keyspaces.AWSKeyspaces.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/ldap/#geniusrise_databases.ldap.LDAP.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/ldap/#geniusrise_databases.ldap.LDAP.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/memsql/#geniusrise_databases.memsql.MemSQL.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/memsql/#geniusrise_databases.memsql.MemSQL.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/mongodb/#geniusrise_databases.mongodb.MongoDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/mongodb/#geniusrise_databases.mongodb.MongoDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/mysql/#geniusrise_databases.mysql.MySQL.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/mysql/#geniusrise_databases.mysql.MySQL.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/neo4j/#geniusrise_databases.neo4j.Neo4j.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/neo4j/#geniusrise_databases.neo4j.Neo4j.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/nuodb/#geniusrise_databases.nuodb.NuoDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/nuodb/#geniusrise_databases.nuodb.NuoDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/opentsdb/#geniusrise_databases.opentsdb.OpenTSDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/opentsdb/#geniusrise_databases.opentsdb.OpenTSDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/oracle/#geniusrise_databases.oracle.Oracle.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/oracle/#geniusrise_databases.oracle.Oracle.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/postgres/#geniusrise_databases.postgres.PostgreSQL.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/postgres/#geniusrise_databases.postgres.PostgreSQL.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/presto/#geniusrise_databases.presto.Presto.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/presto/#geniusrise_databases.presto.Presto.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/redis/#geniusrise_databases.redis.Redis.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/redis/#geniusrise_databases.redis.Redis.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/riak/#geniusrise_databases.riak.Riak.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/riak/#geniusrise_databases.riak.Riak.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/spanner/#geniusrise_databases.spanner.Spanner.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/spanner/#geniusrise_databases.spanner.Spanner.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/sql_server/#geniusrise_databases.sql_server.SQLServer.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/sql_server/#geniusrise_databases.sql_server.SQLServer.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/sqlite/#geniusrise_databases.sqlite.SQLite.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/sqlite/#geniusrise_databases.sqlite.SQLite.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/sybase/#geniusrise_databases.sybase.Sybase.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/sybase/#geniusrise_databases.sybase.Sybase.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/teradata/#geniusrise_databases.teradata.Teradata.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/teradata/#geniusrise_databases.teradata.Teradata.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/tidb/#geniusrise_databases.tidb.TiDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/tidb/#geniusrise_databases.tidb.TiDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargsAny
Additional keyword arguments.
{}"},{"location":"databases/timescaledb/#geniusrise_databases.timescaledb.TimescaleDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/timescaledb/#geniusrise_databases.timescaledb.TimescaleDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/vertica/#geniusrise_databases.vertica.Vertica.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/vertica/#geniusrise_databases.vertica.Vertica.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"databases/voltdb/#geniusrise_databases.voltdb.VoltDB.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"databases/voltdb/#geniusrise_databases.voltdb.VoltDB.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The Geniusrise framework is designed to provide a modular, scalable, and interoperable system for orchestrating machine learning workflows, particularly in the context of Large Language Models (LLMs). The architecture is built around the core concept of a Task, which represents a discrete unit of work. This document provides an overview of the architecture, detailing the primary components and their interactions.
A task is the fundamental unit of work in the Geniusrise framework. It represents a specific operation or computation and can run for an arbitrary amount of time, performing any amount of work.
State Managers play a pivotal role in maintaining the state of tasks. They ensure that the progress and status of tasks are tracked, especially in distributed environments. Geniusrise offers various types of State Managers:
DynamoDBStateManager: Interfaces with Amazon DynamoDB.
InMemoryStateManager: Maintains state within the application's memory.
PostgresStateManager: Interfaces with PostgreSQL databases.
RedisStateManager: Interfaces with Redis in-memory data structure store.
State Managers store data in various locations, allowing organizations to connect dashboards to these storage systems for real-time monitoring and analytics. This centralized storage and reporting mechanism ensures that stakeholders have a unified view of task states.
Data Managers are responsible for handling the input and output data for tasks. They implement various data operations methods that tasks can leverage to ingest or save data during their runs. Data Managers can be categorized based on their function and data processing type:
Data Managers manage data partitioning for both batch and streaming data. By adhering to common data patterns, they enable the system's components to operate independently, fostering the creation of intricate networks of tasks. This independence, while allowing for flexibility and scalability, ensures that cascading failures in one component don't necessarily compromise the entire system.
Model Managers oversee model operations, ensuring that models are saved, loaded, and managed. They can be of two primary types:
S3ModelManager: Interfaces with Amazon S3 for model storage.
WANDBModelManager: Interfaces with Weights & Biases for model versioning.
GitModelManager: Interfaces with Git repositories for versioning of models.
ed40fcb8-ebac-4982-96c4-dc0ffbb0413e
"},{"location":"guides/architecture/#spouts-and-bolts","title":"Spouts and Bolts","text":"
At the heart of the Geniusrise framework are two primary component types: spouts and bolts.
Spouts: These are tasks responsible for ingesting data from various sources. Depending on the output type, spouts can either produce streaming output or batch output.
Batch: Runs periodically, Produces data as a batch output.
Stream: Runs forever, produces data into a streaming output.
Bolts: Bolts are tasks that take in data, process it, and produce output. They can be categorized based on their input and output types:
Stream-Stream: Reads streaming data and produces streaming output.
Stream-Batch: Reads streaming data and produces batch output.
Batch-Stream: Reads batch data and produces streaming output.
Batch-Batch: Reads batch data and produces batch output.
Runners are the backbone of the Geniusrise framework, ensuring that tasks are executed seamlessly across various platforms. They encapsulate the environment and resources required for task execution, abstracting away the underlying complexities. Geniusrise offers the following runners:
Local Runner: Executes tasks directly on a local machine, ideal for development and testing.
Docker Runner: Runs tasks within Docker containers, ensuring a consistent and isolated environment.
Kubernetes Runner: Deploys tasks on Kubernetes clusters, leveraging its scalability and orchestration capabilities.
Airflow Runner: Integrates with Apache Airflow, allowing for complex workflow orchestration and scheduling.
ECS Runner: Executes tasks on AWS ECS, providing a managed container service.
Batch Runner: Optimized for batch computing workloads on platforms like AWS Batch.
: Choose the type of output data: batch or streaming.
{none,redis,postgres,dynamodb,prometheus}
: Select the type of state manager: none, redis, postgres, or dynamodb.
method_name
: The name of the method to execute on the spout.
Options genius TestSpoutCtlSpout rise
--buffer_size BUFFER_SIZE: Specify the size of the buffer. --output_folder OUTPUT_FOLDER: Specify the directory where output files should be stored temporarily
--output_kafka_topic OUTPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --output_kafka_cluster_connection_string OUTPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --output_s3_bucket OUTPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --output_s3_folder OUTPUT_S3_FOLDER: Indicate the S3 folder for output storage. --redis_host REDIS_HOST: Enter the host address for the Redis server. --redis_port REDIS_PORT: Enter the port number for the Redis server. --redis_db REDIS_DB: Specify the Redis database to be used. --postgres_host POSTGRES_HOST: Enter the host address for the PostgreSQL server. --postgres_port POSTGRES_PORT: Enter the port number for the PostgreSQL server. --postgres_user POSTGRES_USER: Provide the username for the PostgreSQL server. --postgres_password POSTGRES_PASSWORD: Provide the password for the PostgreSQL server. --postgres_database POSTGRES_DATABASE: Specify the PostgreSQL database to be used. --postgres_table POSTGRES_TABLE: Specify the PostgreSQL table to be used. --dynamodb_table_name DYNAMODB_TABLE_NAME: Provide the name of the DynamoDB table. --dynamodb_region_name DYNAMODB_REGION_NAME: Specify the AWS region for DynamoDB. --prometheus_gateway PROMETHEUS_GATEWAY: Specify the prometheus gateway URL. --args ...: Additional keyword arguments to pass to the spout.
: Choose the type of output data: batch or streaming.
{none,redis,postgres,dynamodb,prometheus}
: Select the type of state manager: none, redis, postgres, or dynamodb.
{k8s}
: Choose the type of deployment.
method_name
: The name of the method to execute on the spout.
Options genius TestSpoutCtlSpout deploy
--buffer_size BUFFER_SIZE: Specify the size of the buffer. --output_folder OUTPUT_FOLDER: Specify the directory where output files should be stored temporarily
--output_kafka_topic OUTPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --output_kafka_cluster_connection_string OUTPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --output_s3_bucket OUTPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --output_s3_folder OUTPUT_S3_FOLDER: Indicate the S3 folder for output storage. --redis_host REDIS_HOST: Enter the host address for the Redis server. --redis_port REDIS_PORT: Enter the port number for the Redis server. --redis_db REDIS_DB: Specify the Redis database to be used. --postgres_host POSTGRES_HOST: Enter the host address for the PostgreSQL server. --postgres_port POSTGRES_PORT: Enter the port number for the PostgreSQL server. --postgres_user POSTGRES_USER: Provide the username for the PostgreSQL server. --postgres_password POSTGRES_PASSWORD: Provide the password for the PostgreSQL server. --postgres_database POSTGRES_DATABASE: Specify the PostgreSQL database to be used. --postgres_table POSTGRES_TABLE: Specify the PostgreSQL table to be used. --dynamodb_table_name DYNAMODB_TABLE_NAME: Provide the name of the DynamoDB table. --dynamodb_region_name DYNAMODB_REGION_NAME: Specify the AWS region for DynamoDB. --prometheus_gateway PROMETHEUS_GATEWAY: Specify the prometheus gateway URL. --k8s_kind {deployment,service,job,cron_job}: Choose the type of kubernetes resource. --k8s_name K8S_NAME: Name of the Kubernetes resource. --k8s_image K8S_IMAGE: Docker image for the Kubernetes resource. --k8s_replicas K8S_REPLICAS: Number of replicas. --k8s_env_vars K8S_ENV_VARS: Environment variables as a JSON string. --k8s_cpu K8S_CPU: CPU requirements. --k8s_memory K8S_MEMORY: Memory requirements. --k8s_storage K8S_STORAGE: Storage requirements. --k8s_gpu K8S_GPU: GPU requirements. --k8s_kube_config_path K8S_KUBE_CONFIG_PATH: Name of the Kubernetes cluster local config. --k8s_api_key K8S_API_KEY: GPU requirements. --k8s_api_host K8S_API_HOST: GPU requirements. --k8s_verify_ssl K8S_VERIFY_SSL: GPU requirements. --k8s_ssl_ca_cert K8S_SSL_CA_CERT: GPU requirements. --k8s_cluster_name K8S_CLUSTER_NAME: Name of the Kubernetes cluster. --k8s_context_name K8S_CONTEXT_NAME: Name of the kubeconfig context. --k8s_namespace K8S_NAMESPACE: Kubernetes namespace. --k8s_labels K8S_LABELS: Labels for Kubernetes resources, as a JSON string. --k8s_annotations K8S_ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --k8s_port K8S_PORT: Port to run the spout on as a service. --k8s_target_port K8S_TARGET_PORT: Port to expose the spout on as a service. --k8s_schedule K8S_SCHEDULE: Schedule to run the spout on as a cron job. --args ...: Additional keyword arguments to pass to the spout.
: Choose the type of input data: batch or streaming.
{batch,streaming,stream_to_batch}
: Choose the type of output data: batch or streaming.
{none,redis,postgres,dynamodb,prometheus}
: Select the type of state manager: none, redis, postgres, or dynamodb.
method_name
: The name of the method to execute on the bolt.
Options genius TestBoltCtlBolt rise
--buffer_size BUFFER_SIZE: Specify the size of the buffer. --input_folder INPUT_FOLDER: Specify the directory where output files should be stored temporarily
--input_kafka_topic INPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --input_kafka_cluster_connection_string INPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --input_kafka_consumer_group_id INPUT_KAFKA_CONSUMER_GROUP_ID: Kafka consumer group id to use. --input_s3_bucket INPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --input_s3_folder INPUT_S3_FOLDER: Indicate the S3 folder for output storage. --output_folder OUTPUT_FOLDER: Specify the directory where output files should be stored temporarily
--output_kafka_topic OUTPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --output_kafka_cluster_connection_string OUTPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --output_s3_bucket OUTPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --output_s3_folder OUTPUT_S3_FOLDER: Indicate the S3 folder for output storage. --redis_host REDIS_HOST: Enter the host address for the Redis server. --redis_port REDIS_PORT: Enter the port number for the Redis server. --redis_db REDIS_DB: Specify the Redis database to be used. --postgres_host POSTGRES_HOST: Enter the host address for the PostgreSQL server. --postgres_port POSTGRES_PORT: Enter the port number for the PostgreSQL server. --postgres_user POSTGRES_USER: Provide the username for the PostgreSQL server. --postgres_password POSTGRES_PASSWORD: Provide the password for the PostgreSQL server. --postgres_database POSTGRES_DATABASE: Specify the PostgreSQL database to be used. --postgres_table POSTGRES_TABLE: Specify the PostgreSQL table to be used. --dynamodb_table_name DYNAMODB_TABLE_NAME: Provide the name of the DynamoDB table. --dynamodb_region_name DYNAMODB_REGION_NAME: Specify the AWS region for DynamoDB. --prometheus_gateway PROMETHEUS_GATEWAY: Specify the prometheus gateway URL. --args ...: Additional keyword arguments to pass to the bolt.
: Choose the type of input data: batch or streaming.
{batch,streaming,stream_to_batch}
: Choose the type of output data: batch or streaming.
{none,redis,postgres,dynamodb,prometheus}
: Select the type of state manager: none, redis, postgres, or dynamodb.
{k8s}
: Choose the type of deployment.
method_name
: The name of the method to execute on the spout.
Options genius TestBoltCtlBolt deploy
--buffer_size BUFFER_SIZE: Specify the size of the buffer. --input_folder INPUT_FOLDER: Specify the directory where output files should be stored temporarily
--input_kafka_topic INPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --input_kafka_cluster_connection_string INPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --input_kafka_consumer_group_id INPUT_KAFKA_CONSUMER_GROUP_ID: Kafka consumer group id to use. --input_s3_bucket INPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --input_s3_folder INPUT_S3_FOLDER: Indicate the S3 folder for output storage. --output_folder OUTPUT_FOLDER: Specify the directory where output files should be stored temporarily
--output_kafka_topic OUTPUT_KAFKA_TOPIC: Kafka output topic for streaming spouts. --output_kafka_cluster_connection_string OUTPUT_KAFKA_CLUSTER_CONNECTION_STRING: Kafka connection string for streaming spouts. --output_s3_bucket OUTPUT_S3_BUCKET: Provide the name of the S3 bucket for output storage. --output_s3_folder OUTPUT_S3_FOLDER: Indicate the S3 folder for output storage. --redis_host REDIS_HOST: Enter the host address for the Redis server. --redis_port REDIS_PORT: Enter the port number for the Redis server. --redis_db REDIS_DB: Specify the Redis database to be used. --postgres_host POSTGRES_HOST: Enter the host address for the PostgreSQL server. --postgres_port POSTGRES_PORT: Enter the port number for the PostgreSQL server. --postgres_user POSTGRES_USER: Provide the username for the PostgreSQL server. --postgres_password POSTGRES_PASSWORD: Provide the password for the PostgreSQL server. --postgres_database POSTGRES_DATABASE: Specify the PostgreSQL database to be used. --postgres_table POSTGRES_TABLE: Specify the PostgreSQL table to be used. --dynamodb_table_name DYNAMODB_TABLE_NAME: Provide the name of the DynamoDB table. --dynamodb_region_name DYNAMODB_REGION_NAME: Specify the AWS region for DynamoDB. --prometheus_gateway PROMETHEUS_GATEWAY: Specify the prometheus gateway URL. --k8s_kind {deployment,service,job,cron_job}: Choose the type of kubernetes resource. --k8s_name K8S_NAME: Name of the Kubernetes resource. --k8s_image K8S_IMAGE: Docker image for the Kubernetes resource. --k8s_replicas K8S_REPLICAS: Number of replicas. --k8s_env_vars K8S_ENV_VARS: Environment variables as a JSON string. --k8s_cpu K8S_CPU: CPU requirements. --k8s_memory K8S_MEMORY: Memory requirements. --k8s_storage K8S_STORAGE: Storage requirements. --k8s_gpu K8S_GPU: GPU requirements. --k8s_kube_config_path K8S_KUBE_CONFIG_PATH: Name of the Kubernetes cluster local config. --k8s_api_key K8S_API_KEY: GPU requirements. --k8s_api_host K8S_API_HOST: GPU requirements. --k8s_verify_ssl K8S_VERIFY_SSL: GPU requirements. --k8s_ssl_ca_cert K8S_SSL_CA_CERT: GPU requirements. --k8s_cluster_name K8S_CLUSTER_NAME: Name of the Kubernetes cluster. --k8s_context_name K8S_CONTEXT_NAME: Name of the kubeconfig context. --k8s_namespace K8S_NAMESPACE: Kubernetes namespace. --k8s_labels K8S_LABELS: Labels for Kubernetes resources, as a JSON string. --k8s_annotations K8S_ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --k8s_port K8S_PORT: Port to run the spout on as a service. --k8s_target_port K8S_TARGET_PORT: Port to expose the spout on as a service. --k8s_schedule K8S_SCHEDULE: Schedule to run the spout on as a cron job. --args ...: Additional keyword arguments to pass to the spout.
--spout SPOUT: Name of the specific spout to run. --bolt BOLT: Name of the specific bolt to run. --file FILE: Path of the genius.yml file, default to .
Options genius rise
--spout SPOUT: Name of the specific spout to run. --bolt BOLT: Name of the specific bolt to run. --file FILE: Path of the genius.yml file, default to .
usage: genius pod [-h] {status,show,describe,logs} ...
POSITIONAL ARGUMENTS genius pod
genius pod status
: Get the status of the Kubernetes pod.
genius pod show
: List all pods.
genius pod describe
: Describe a pod.
genius pod logs
: Get the logs of a pod.
"},{"location":"guides/cli/#command-genius-pod-status","title":"Command: genius pod status","text":"
usage: genius pod status [-h] [--kube_config_path KUBE_CONFIG_PATH] [--cluster_name CLUSTER_NAME] [--context_name CONTEXT_NAME] [--namespace NAMESPACE] [--labels LABELS] [--annotations ANNOTATIONS] [--api_key API_KEY] [--api_host API_HOST] [--verify_ssl VERIFY_SSL] [--ssl_ca_cert SSL_CA_CERT] name
name
: Name of the Kubernetes pod.
Options genius pod status
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-pod-show","title":"Command: genius pod show","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-pod-describe","title":"Command: genius pod describe","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-pod-logs","title":"Command: genius pod logs","text":"
--follow FOLLOW: Whether to follow the logs. --tail TAIL: Number of lines to show from the end of the logs. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--replicas REPLICAS: Number of replicas. --env_vars ENV_VARS: Environment variables as a JSON string. --cpu CPU: CPU requirements. --memory MEMORY: Memory requirements. --storage STORAGE: Storage requirements. --gpu GPU: GPU requirements. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--replicas REPLICAS: Number of replicas. --port PORT: Service port. --target_port TARGET_PORT: Container target port. --env_vars ENV_VARS: Environment variables as a JSON string. --cpu CPU: CPU requirements. --memory MEMORY: Memory requirements. --storage STORAGE: Storage requirements. --gpu GPU: GPU requirements. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-service-delete","title":"Command: genius service delete","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-service-describe","title":"Command: genius service describe","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
"},{"location":"guides/cli/#command-genius-service-show","title":"Command: genius service show","text":"
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--env_vars ENV_VARS: Environment variables as a JSON string. --cpu CPU: CPU requirements. --memory MEMORY: Memory requirements. --storage STORAGE: Storage requirements. --gpu GPU: GPU requirements. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--env_vars ENV_VARS: Environment variables as a JSON string. --cpu CPU: CPU requirements. --memory MEMORY: Memory requirements. --storage STORAGE: Storage requirements. --gpu GPU: GPU requirements. --kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--kube_config_path KUBE_CONFIG_PATH: Path to the kubeconfig file. --cluster_name CLUSTER_NAME: Name of the Kubernetes cluster. --context_name CONTEXT_NAME: Name of the kubeconfig context. --namespace NAMESPACE: Kubernetes namespace. --labels LABELS: Labels for Kubernetes resources, as a JSON string. --annotations ANNOTATIONS: Annotations for Kubernetes resources, as a JSON string. --api_key API_KEY: API key for Kubernetes cluster. --api_host API_HOST: API host for Kubernetes cluster. --verify_ssl VERIFY_SSL: Whether to verify SSL certificates. --ssl_ca_cert SSL_CA_CERT: Path to the SSL CA certificate.
--auth AUTH: Authentication credentials as a JSON string. --base_image BASE_IMAGE: The base image to use for the Docker container. --workdir WORKDIR: The working directory in the Docker container. --local_dir LOCAL_DIR: The local directory to copy into the Docker container. --packages [PACKAGES ...]: List of Python packages to install in the Docker container. --os_packages [OS_PACKAGES ...]: List of OS packages to install in the Docker container. --env_vars ENV_VARS: Environment variables to set in the Docker container.
The Geniusrise framework is built around loosely-coupled modules acting as a cohesive adhesive between distinct, modular components, much like how one would piece together Lego blocks. This design approach not only promotes flexibility but also ensures that each module or \"Lego block\" remains sufficiently independent. Such independence is crucial for diverse teams, each with its own unique infrastructure and requirements, to seamlessly build and manage their respective components.
Geniusrise comes with a sizable set of plugins which implement various features and integrations. The independence and modularity of the design enable sharing of these building blocks in the community.
Task: At its core, a task represents a discrete unit of work within the Geniusrise framework. Think of it as a singular action or operation that the system needs to execute. A task further manifests itself into a Bolt or a Spout as stated below.
Components of a Task: Each task is equipped with four components:
State Manager: This component is responsible for continuously monitoring and managing the task's state, ensuring that it progresses smoothly from initiation to completion and to report errors and ship logs into a central location.
Data Manager: As the name suggests, the Data Manager oversees the input and output data associated with a task, ensuring data integrity and efficient data flow. It also ensures data sanity follows partition semantics and isolation.
Runner: These are wrappers for executing a task on various platforms. Depending on the platform, the runner ensures that the task is executed seamlessly.
Task Classification: Tasks within the Geniusrise framework can be broadly classified into two categories:
Spout: If a task's primary function is to ingest or bring in data, it's termed as a 'spout'.
Bolt: For tasks that don't primarily ingest data but perform other operations, they are termed 'bolts'.
The beauty of the Geniusrise framework lies in its adaptability. Developers can script their workflow components once and have the freedom to deploy them across various platforms. To facilitate this, Geniusrise offers:
Runners for Task Execution: Geniusrise is equipped with a diverse set of runners, each tailored for different platforms, ensuring that tasks can be executed almost anywhere:
On your local machine for quick testing and development.
Within Docker containers for isolated, reproducible environments.
On Kubernetes clusters for scalable, cloud-native deployments.
Using Apache Airflow for complex workflow orchestration. (Coming Soon).
On AWS ECS for containerized application management. (Coming Soon).
With AWS Batch for efficient batch computing workloads. (Coming Soon).
With Docker Swarm clusters as an alternative orchestrator to kubernetes. (Coming Soon).
This document delves into the core components and concepts that make up the Geniusrise framework.
Because of the very loose coupling of the components, though the framework can be used to build very complex networks with independently running nodes, it provides limited orchestration capability, like synchronous pipelines. An external orchestrator like airflow can be used in such cases to orchestrate geniusrise components.
This guide provides comprehensive instructions on how to deploy and manage resources in a Kubernetes cluster using the Geniusrise platform. The guide covers the following functionalities:
"},{"location":"guides/deployment/#managing-pods","title":"Managing Pods","text":""},{"location":"guides/deployment/#checking-pod-status","title":"Checking Pod Status","text":"
To get the status of a specific pod:
genius k8s status my-pod-name --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#listing-all-pods","title":"Listing All Pods","text":"
To list all the pods in the current namespace:
genius k8s show --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#describing-a-pod","title":"Describing a Pod","text":"
"},{"location":"guides/deployment/#managing-deployments","title":"Managing Deployments","text":""},{"location":"guides/deployment/#creating-a-new-deployment","title":"Creating a New Deployment","text":"
"},{"location":"guides/deployment/#managing-services","title":"Managing Services","text":""},{"location":"guides/deployment/#creating-a-new-service","title":"Creating a New Service","text":"
"},{"location":"guides/deployment/#deleting-a-service","title":"Deleting a Service","text":"
To delete a service:
genius service delete --name example-service --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#describing-a-service","title":"Describing a Service","text":"
To describe a specific service:
genius service describe --name example-service --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#listing-all-services","title":"Listing All Services","text":"
To list all services:
genius service show --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#managing-jobs","title":"Managing Jobs","text":""},{"location":"guides/deployment/#creating-a-new-job","title":"Creating a New Job","text":"
genius job status --name example-job --namespace geniusrise \\\n--context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev\n
"},{"location":"guides/deployment/#managing-cron-jobs","title":"Managing Cron Jobs","text":""},{"location":"guides/deployment/#creating-a-new-cron-job","title":"Creating a New Cron Job","text":"
To create a new cron job, you can use the create_cronjob sub-command. You'll need to specify the name, Docker image, command to run, and the cron schedule.
"},{"location":"guides/deployment/#advanced-features-for-cron-jobs","title":"Advanced Features for Cron Jobs","text":""},{"location":"guides/deployment/#environment-variables_1","title":"Environment Variables","text":"
You can pass environment variables to your cron jobs like so:
SNOMED-CT: is a knowledge graph of standard medical terminology
IHTSDO: a standards body for medical terminologies in a number of countries.
UMLS: unified medical language system is a set of files and software that brings together many health and biomedical vocabularies and standards together.
"},{"location":"guides/dev_cycle/#strategy-1-named-entity-recognition","title":"Strategy 1: Named entity recognition","text":""},{"location":"guides/dev_cycle/#1-create-a-labelled-dataset","title":"1. Create a labelled dataset","text":"
We need a corpus of documents with medical terms labeled. For example, we could use wikipedia + wikidata to build such a dataset, given entities in wikipedia are linked and indexed in the wikidata knowledge graph. Reference: Building a Massive Corpus for Named Entity Recognition using Free Open Data Sources. We could also annotate medical datasets like MIMIC-III annotated with SNOMED-CT based MedCAT which is a medical annotation tool developed on the knowledge graph of medical terminology (SNOMED-CT), as it would be more pertinent to our usecase, reference: DNER Clinical (named entity recognition) from free clinical text to Snomed-CT concept
"},{"location":"guides/dev_cycle/#2-train-a-model-on-the-ner-dataset","title":"2. Train a model on the NER dataset","text":"
We could choose a large language model and train the model on the NER fine-tuning task. The model would then be able to recognize and tag medical terms in any given text data.
We use an LLM to create a vectorized layer over SNOMED-CT. This layer can be used to semantically search for \"seed\" nodes in the graph. We can then use these seed nodes to traverse nodes a few hops adjacent to the seed nodes.
We use the knowledge graph search results to not only annotate each node seen in the EHR document, but also add additional information about those nodes derived from its adjacent nodes. But first, we also need to make sure that we query the right information instead of simply vectorized chunks and throwing it at semantic search. We would need a \"traditional\" pipeline for this - lemmatization followed by POS tagging. We use both proper nouns and out of vocabulary words as search query terms.
"},{"location":"guides/dev_cycle/#preparing-the-knowledge-graph","title":"Preparing the knowledge graph","text":"
Lets prepare the knowledge graph by vectorizing each node's knowledge into a vectorized flat memory. This is a periodic activity that one needs to do whenever a new version of SNOMED-CT is released (typically bi-annually).
We use the international version of SNOMED-CT from https://www.nlm.nih.gov/healthit/snomedct/international.html.
mkdir data\ncd data\n
Go to UMLS or IHTSDO website, register, agree to the agreements and after approval, download the knowledge graph.
Geniusrise is composed of the core framework and various plugins that implement specific tasks. The core has to be installed first, and after that selected plugins can be installed as and when required.
Geniusrise containers are available on Docker hub.
docker run -it --rm geniusrise/geniusrise:latest\n``` -->\n\n## Installing Plugins\n---\n\nGeniusrise offers a variety of plugins that act as composable lego blocks. To install a specific plugin, use the following format:\n\n```bash\npip install geniusrise-<plugin-name>\n
Replace <plugin-name> with the name of the desired plugin.
Available plugins are:
geniusrise-text: bolts for text models
geniusrise-vision: bolts for vision models
geniusrise-audio: bolts for audio models
geniusrise-openai: bolts for openai
geniusrise-listeners: spouts for streaming event listeners
geniusrise-databases: spouts for databases
Please visit https://github.com/geniusrise for a complete list of available plugins.
In this example, the --config=my_config.yaml would be used to read the common arguments from the YAML file, and the rest of the arguments would be taken from the command line.
Lets create a workspace for local experimentation. We will not build anything here, just try to use whatever components are available. This is what a low-code workflow could look like.
Lets create a workflow in which:
A web server listens for all kinds of HTTP events.
Clients send the following information to the server:
HTTP request
Response and response status code
The server buffers events in batches of 1000 and uploads them on to s3.
Train a small LLM model on the data to be used to predict whether the request was valid.
A representation of the process using a sequence diagram:
e451c317-1904-43cc-ad92-e5146e70eb14
This model could be used to predict if a request will fail before serving it. It could also be used to classify requests as malicious etc.
\ud83d\ude80 Initialized Task with ID: Webhookaca9cb67-5c41-420c-9445-cf0015d9d866\n [17/Sep/2023:14:00:18] ENGINE Bus STARTING\nCherryPy Checker:\nThe Application mounted at '' has an empty config.\n\n[17/Sep/2023:14:00:18] ENGINE Started monitor thread 'Autoreloader'.\n [17/Sep/2023:14:00:18] ENGINE Serving on http://0.0.0.0:8080\n [17/Sep/2023:14:00:18] ENGINE Bus STARTED\n
while true; do\n# Generate a random customer ID\ncustomer_id=$(( RANDOM % 10000001 ))\n# Determine the status code based on the customer ID\nif [ $customer_id -gt 10000000 ]; then\nstatus_code=\"1\"\nelif [ $customer_id -le 10000 ]; then\nstatus_code=\"1\"\nelse\nstatus_code=\"0\"\nfi\n# Make the API call\ncurl --header \"Content-Type: application/json\" \\\n--request POST \\\n--data \"{\\\"text\\\":\\\"GET /api/v1/customer/$customer_id\\\",\\\"label\\\":\\\"$status_code\\\"}\" \\\nhttp://localhost:8080/application-1-tag-a-tag-b-whatever\ndone\n
Verify that the data is being dumped in the right place with the correct format:
Now lets test the second leg of this, the model. Since we want to use the model for predicting the status code given the data, we will use classification as our task for fine-tuning the model.
Lets use the bert-base-uncased model for now, as it is small enough to run on a CPU on a laptop. We also create a model on huggingface hub to store the model once it is trained: ixaxaar/geniusrise-api-status-code-prediction.
\ud83d\ude80 Initialized Task with ID: HuggingFaceClassificationFineTuner772627a0-43a5-4f9d-9b0f-4362d69ba08c\n Found credentials in shared credentials file: ~/.aws/credentials\nSome weights of BertForSequenceClassification were not initialized from the model checkpoint at bert-base-uncased and are newly initialized: ['classifier.bias', 'classifier.weight']\nYou should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n Loading dataset from /tmp/tmp3h3wav4h/train\n New labels detected, ignore if fine-tuning\nMap: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 300/300 [00:00<00:00, 4875.76 examples/s]\n{'train_runtime': 13.3748, 'train_samples_per_second': 44.861, 'train_steps_per_second': 22.43, 'train_loss': 0.6400579833984374, 'epoch': 2.0}\n100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 300/300 [00:13<00:00, 22.43it/s]\npytorch_model.bin: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 438M/438M [01:29<00:00, 4.88MB/s]\n Successfully executed the bolt method: fine_tune \ud83d\udc4d\n
You'll see a progress bar at the bottom, on completion, a pull request will appear on huggingface hub. Here is the model we trained: https://huggingface.co/ixaxaar/geniusrise-api-status-code-prediction.
"},{"location":"guides/packaging/#complex-examples","title":"Complex Examples","text":""},{"location":"guides/packaging/#1-uploading-to-ecr-with-custom-base-image-and-packages","title":"1. Uploading to ECR with Custom Base Image and Packages","text":"
This example demonstrates how to upload a Docker image to ECR with a custom base image and additional Python packages.
"},{"location":"guides/packaging/#2-uploading-to-dockerhub-with-environment-variables-and-working-directory","title":"2. Uploading to DockerHub with Environment Variables and Working Directory","text":"
This example shows how to upload a Docker image to DockerHub with custom environment variables and a specific working directory.
"},{"location":"guides/packaging/#3-uploading-to-acr-with-multiple-local-directories","title":"3. Uploading to ACR with Multiple Local Directories","text":"
In this example, we upload a Docker image to Azure Container Registry (ACR) and specify multiple local directories to be copied into the Docker container.
# First, create a Dockerfile that copies multiple directories\n# Then use the following command\ngenius docker package multi_dir_app acr \\\n--auth '{\"acr_username\": \"username\", \"acr_password\": \"password\", \"acr_login_server\": \"login_server\"}' \\\n--local_dir \"./app ./config\"\n
"},{"location":"guides/packaging/#4-uploading-to-gcr-with-custom-base-image-packages-and-os-packages","title":"4. Uploading to GCR with Custom Base Image, Packages, and OS Packages","text":"
This example demonstrates how to upload a Docker image to Google Container Registry (GCR) with a custom base image, Python packages, and OS packages.
"},{"location":"guides/packaging/#5-uploading-to-quay-with-all-customizations","title":"5. Uploading to Quay with All Customizations","text":"
This example shows how to upload a Docker image to Quay with all available customizations like base image, working directory, local directory, Python packages, OS packages, and environment variables.
The TTGO T-Camera Plus is a unique ESP32 module featuring a built-in camera and display. It's designed for applications that require direct image capture and display capabilities without the need for external screens or cameras.
CPU: Dual-core Tensilica LX6 microprocessor up to 240 MHz
Memory: 520 KB SRAM, 4 MB PSRAM
Connectivity: Wi-Fi (802.11 b/g/n), Bluetooth (Classic and BLE)
Camera: OV2640 camera module, 2 Megapixels
Display: 1.3-inch OLED display
Extras: Fish-eye lens, optional MPU6050 module for motion sensing
"},{"location":"guides/pin/#seeed-studio-xiao","title":"Seeed Studio XIAO","text":"
Seeed Studio XIAO ESP32C3 is a mini but powerful module. It's part of the Seeed Studio XIAO series, known for its compact design and reliability in various IoT projects.
CPU: RISC-V single-core processor, up to 160 MHz
Memory: 400 KB SRAM, 4 MB Flash
Connectivity: Wi-Fi (802.11 b/g/n), Bluetooth 5 (LE)
I/O Pins: Rich set of peripherals including GPIOs, UART, SPI, I2C, and more.
Size: Ultra-small form factor suitable for wearable devices and compact projects
We used a bunch of these peripherals wherever the boards did not have them. We usually chose a platform with at least a screen and a camera included and added these peripherals to them.
Power Supply: Ensure that all devices are powered appropriately. The XIAO and TTGO can be powered via USB or an external 3.3V power supply.
Common Ground: Make sure all components share a common ground connection.
Programming: Use the Arduino IDE or ESP-IDF for programming the ESP32 devices. Libraries specific to the peripherals (e.g., display, I2S microphone, and speaker) will be required.
I2S Library: For the INMP441 microphone, an I2S library suitable for ESP32 should be used to handle audio input.
Display Library: For the touchscreen display, a library compatible with the specific model will be needed for interfacing and graphics rendering.
"},{"location":"guides/yaml/#example-3-bolt-with-postgres-state-and-ecs-deployment","title":"Example 3: Bolt with Postgres State and ECS Deployment","text":"
"},{"location":"guides/yaml/#example-4-spout-with-s3-state-and-lambda-deployment","title":"Example 4: Spout with S3 State and Lambda Deployment","text":"
"},{"location":"guides/yaml/#example-5-bolt-with-dynamodb-state-and-fargate-deployment","title":"Example 5: Bolt with DynamoDB State and Fargate Deployment","text":"
"},{"location":"guides/yaml/#example-6-spout-and-bolt-with-azure-blob-storage-and-azure-functions","title":"Example 6: Spout and Bolt with Azure Blob Storage and Azure Functions","text":"
You can manage Kubernetes deployments using the genius CLI. Here are some example commands:
# Show pods in a namespace\ngenius pod show --namespace geniusrise --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise\n\n# Scale a deployment\ngenius pod scale --namespace geniusrise --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise --name testspout --replicas 3\n# Delete a deployment\ngenius pod delete --namespace geniusrise --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise --name testspout\n
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/activemq/#activemq.ActiveMQ.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/activemq/#activemq.ActiveMQ.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/amqp/#amqp.RabbitMQ.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/amqp/#amqp.RabbitMQ.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/grpc/#grpc.Grpc.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/grpc/#grpc.Grpc.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/http_polling/#http_polling.RESTAPIPoll.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/http_polling/#http_polling.RESTAPIPoll.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/kafka/#kafka.Kafka.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/kafka/#kafka.Kafka.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/kinesis/#kinesis.Kinesis.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/kinesis/#kinesis.Kinesis.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/mqtt/#mqtt.MQTT.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/mqtt/#mqtt.MQTT.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/quic/#quic.Quic.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/quic/#quic.Quic.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/redis_pubsub/#redis_pubsub.RedisPubSub.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/redis_pubsub/#redis_pubsub.RedisPubSub.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/redis_streams/#redis_streams.RedisStream.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/redis_streams/#redis_streams.RedisStream.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/sns/#sns.SNS.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/socket.io/#socketio.SocketIo.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/socket.io/#socketio.SocketIo.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/sqs/#sqs.SQS.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/udp/#udp.Udp.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/webhook/#webhook.Webhook.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/webhook/#webhook.Webhook.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/websocket/#websocket.Websocket.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/websocket/#websocket.Websocket.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
Name Type Description Default outputStreamingOutput
An instance of the StreamingOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"listeners/zeromq/#zeromq.ZeroMQ.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"listeners/zeromq/#zeromq.ZeroMQ.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The ConvertImage class is designed to convert images from one format to another. It takes an input folder containing images and an output format as arguments. The class iterates through each image file in the specified folder and converts it to the desired format. Additional options like quality and subsampling can be specified for lossy formats like 'JPG'.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ConvertImage/#geniusrise_ocr.readers.image.ConvertImage.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ConvertImage/#geniusrise_ocr.readers.image.ConvertImage.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
\ud83d\udcd6 Convert images in the given input folder to the specified output format.
Parameters:
Name Type Description Default output_formatstr
The format to convert images to ('PNG' or 'JPG').
required qualityOptional[int]
The quality of the output image for lossy formats like 'JPG'. Defaults to None.
NonesubsamplingOptional[int]
The subsampling factor for JPEG compression. Defaults to 0.
0
This method iterates through each image file in the specified folder, reads the image, and converts it to the specified output format. Additional parameters like quality and subsampling can be set for lossy formats.
The FineTunePix2Struct class is designed to fine-tune the Pix2Struct model on a custom OCR dataset. It supports three popular OCR dataset formats: COCO, ICDAR, and SynthText.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required model_namestr
The name of the Pix2Struct model to use. Default is \"google/pix2struct-large\".
'google/pix2struct-large'**kwargs
Additional keyword arguments.
{} Dataset Formats
COCO: Assumes a folder structure with an 'annotations.json' file containing image and text annotations.
ICDAR: Assumes a folder structure with 'Images' and 'Annotations' folders containing image files and XML annotation files respectively.
SynthText: Assumes a folder with image files and corresponding '.txt' files containing ground truth text.
"},{"location":"ocr/FineTunePix2Struct/#geniusrise_ocr.ocr.pix2struct.fine_tune.FineTunePix2Struct.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/FineTunePix2Struct/#geniusrise_ocr.ocr.pix2struct.fine_tune.FineTunePix2Struct.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
\ud83d\udcd6 Fine-tune the Pix2Struct model on a custom OCR dataset.
Parameters:
Name Type Description Default epochsint
Number of training epochs.
required batch_sizeint
Batch size for training.
required learning_ratefloat
Learning rate for the optimizer.
required dataset_formatstr
Format of the OCR dataset. Supported formats are \"coco\", \"icdar\", and \"synthtext\".
required use_cudabool
Whether to use CUDA for training. Default is False.
False
This method fine-tunes the Pix2Struct model using the images and annotations in the dataset specified by dataset_format. The fine-tuned model is saved to the specified output path.
"},{"location":"ocr/FineTuneTROCR/","title":"OCR API using trocr","text":"
The FineTuneTROCR class is designed to fine-tune the TROCR model on a custom OCR dataset. It supports three popular OCR dataset formats: COCO, ICDAR, and SynthText.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{} Dataset Formats
COCO: Assumes a folder structure with an 'annotations.json' file containing image and text annotations.
ICDAR: Assumes a folder structure with 'Images' and 'Annotations' folders containing image files and XML annotation files respectively.
SynthText: Assumes a folder with image files and corresponding '.txt' files containing ground truth text.
"},{"location":"ocr/FineTuneTROCR/#geniusrise_ocr.ocr.trocr.fine_tune.FineTuneTROCR.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/FineTuneTROCR/#geniusrise_ocr.ocr.trocr.fine_tune.FineTuneTROCR.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
\ud83d\udcd6 Fine-tune the TROCR model on a custom OCR dataset.
Parameters:
Name Type Description Default epochsint
Number of training epochs.
required batch_sizeint
Batch size for training.
required learning_ratefloat
Learning rate for the optimizer.
required dataset_formatstr
Format of the OCR dataset. Supported formats are \"coco\", \"icdar\", and \"synthtext\".
required use_cudabool
Whether to use CUDA for training. Default is False.
False
This method fine-tunes the TROCR model using the images and annotations in the dataset specified by dataset_format. The fine-tuned model is saved to the specified output path.
The ImageClassPredictor class classifies images using a pre-trained PyTorch model. It assumes that the input.input_folder contains sub-folders of images to be classified. The classified images are saved in output.output_folder, organized by their predicted labels.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ImageClassPredictor/#geniusrise_ocr.classification.predict.ImageClassPredictor.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/ImageClassPredictor/#geniusrise_ocr.classification.predict.ImageClassPredictor.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
\ud83d\udcd6 Classify images in the input sub-folders using a pre-trained PyTorch model.
Parameters:
Name Type Description Default classesstr
JSON string mapping class indices to labels.
required model_pathstr
Path to the pre-trained PyTorch model.
required use_cudabool
Whether to use CUDA for model inference. Default is False.
False
This method iterates through each image file in the specified sub-folders, applies the model, and classifies the image. The classified images are then saved in an output folder, organized by their predicted labels.
The ParseCBZCBR class is designed to process CBZ and CBR files, which are commonly used for comic books. It takes an input folder containing CBZ/CBR files as an argument and iterates through each file. For each file, it extracts the images and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseCBZCBR/#geniusrise_ocr.readers.cbz_cbr.ParseCBZCBR.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ParseCBZCBR/#geniusrise_ocr.readers.cbz_cbr.ParseCBZCBR.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The ParseDjvu class is designed to process DJVU files and classify them as either text-based or image-based. It takes an input folder containing DJVU files as an argument and iterates through each file. For each DJVU, it samples a few pages to determine the type of content it primarily contains. If the DJVU is text-based, the class extracts the text from each page and saves it as a JSON file. If the DJVU is image-based, it converts each page to a PNG image and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseDjvu/#geniusrise_ocr.readers.djvu.ParseDjvu.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
\ud83d\udcd6 Process DJVU files in the given input folder and classify them as text-based or image-based.
Parameters:
Name Type Description Default input_folderstr
The folder containing DJVU files to process.
None
This method iterates through each DJVU file in the specified folder, reads a sample of pages, and determines whether the DJVU is text-based or image-based. It then delegates further processing to _process_text_djvu or _process_image_djvu based on this determination.
The ParseEpub class is designed to process EPUB files and classify them as either text-based or image-based. It takes an input folder containing EPUB files as an argument and iterates through each file. For each EPUB, it samples a few items to determine the type of content it primarily contains. If the EPUB is text-based, the class extracts the text from each item and saves it as a JSON file. If the EPUB is image-based, it saves the images in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseEpub/#geniusrise_ocr.readers.epub.ParseEpub.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
\ud83d\udcd6 Process EPUB files in the given input folder and classify them as text-based or image-based.
Parameters:
Name Type Description Default input_folderstr
The folder containing EPUB files to process.
None
This method iterates through each EPUB file in the specified folder, reads a sample of items, and determines whether the EPUB is text-based or image-based. It then delegates further processing to _process_text_epub or _process_image_epub based on this determination.
The ParseMOBI class is designed to process MOBI files. It takes an input folder containing MOBI files as an argument and iterates through each file. For each file, it extracts the images and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseMOBI/#geniusrise_ocr.readers.mobi.ParseMOBI.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ParseMOBI/#geniusrise_ocr.readers.mobi.ParseMOBI.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The ParsePdf class is designed to process PDF files and classify them as either text-based or image-based. It takes an input folder containing PDF files as an argument and iterates through each file. For each PDF, it samples a few pages to determine the type of content it primarily contains. If the PDF is text-based, the class extracts the text from each page and saves it as a JSON file. If the PDF is image-based, it converts each page to a PNG image and saves them in a designated output folder.
Args:\n input (BatchInput): An instance of the BatchInput class for reading the data.\n output (BatchOutput): An instance of the BatchOutput class for saving the data.\n state (State): An instance of the State class for maintaining the state.\n **kwargs: Additional keyword arguments.\n
"},{"location":"ocr/ParsePdf/#geniusrise_ocr.readers.pdf.ParsePdf.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ParsePdf/#geniusrise_ocr.readers.pdf.ParsePdf.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
\ud83d\udcd6 Process PDF files in the given input folder and classify them as text-based or image-based.
Parameters:
Name Type Description Default input_folderstr
The folder containing PDF files to process.
None
This method iterates through each PDF file in the specified folder, reads a sample of pages, and determines whether the PDF is text-based or image-based. It then delegates further processing to _process_text_pdf or _process_image_pdf based on this determination.
The ParsePostScript class is designed to process PostScript files and classify them as either text-based or image-based. It takes an input folder containing PostScript files as an argument and iterates through each file. For each PostScript file, it converts it to PDF and samples a few pages to determine the type of content it primarily contains. If the PostScript is text-based, the class extracts the text from each page and saves it as a JSON file. If the PostScript is image-based, it converts each page to a PNG image and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParsePostScript/#geniusrise_ocr.readers.postscript.ParsePostScript.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
\ud83d\udcd6 Process PostScript files in the given input folder and classify them as text-based or image-based.
Parameters:
Name Type Description Default input_folderstr
The folder containing PostScript files to process.
None
This method iterates through each PostScript file in the specified folder, converts it to PDF, reads a sample of pages, and determines whether the PostScript is text-based or image-based. It then delegates further processing to _process_text_ps or _process_image_ps based on this determination.
The ParseXPS class is designed to process XPS files. It takes an input folder containing XPS files as an argument and iterates through each file. For each file, it extracts the images and saves them in a designated output folder.
Parameters:
Name Type Description Default inputBatchInput
An instance of the BatchInput class for reading the data.
required outputBatchOutput
An instance of the BatchOutput class for saving the data.
required stateState
An instance of the State class for maintaining the state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/ParseXPS/#geniusrise_ocr.readers.xps.ParseXPS.__init__--using-geniusrise-to-invoke-via-command-line","title":"Using geniusrise to invoke via command line","text":"
"},{"location":"ocr/ParseXPS/#geniusrise_ocr.readers.xps.ParseXPS.__init__--using-geniusrise-to-invoke-via-yaml-file","title":"Using geniusrise to invoke via YAML file","text":"
The Pix2StructImageOCR class performs OCR on images using Google's Pix2Struct model. It expects the input.input_folder to contain the images for OCR and saves the OCR results as JSON files in output.output_folder.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required model_namestr
The name of the Pix2Struct model to use. Default is \"google/pix2struct-large\".
'google/pix2struct-large'**kwargs
Additional keyword arguments.
{}"},{"location":"ocr/Pix2StructImageOCR/#geniusrise_ocr.ocr.pix2struct.bulk.Pix2StructImageOCR.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/Pix2StructImageOCR/#geniusrise_ocr.ocr.pix2struct.bulk.Pix2StructImageOCR.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
The Pix2StructImageOCRAPI class performs OCR on images using Google's Pix2Struct model. The class exposes an API endpoint for OCR on single images. The endpoint is accessible at /api/v1/ocr. The API takes a POST request with a JSON payload containing a base64 encoded image under the key image_base64. It returns a JSON response containing the OCR result under the key ocr_text.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required model_namestr
The name of the Pix2Struct model to use. Default is \"google/pix2struct-large\".
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/Pix2StructImageOCRAPI/#geniusrise_ocr.ocr.pix2struct.api.Pix2StructImageOCRAPI.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/Pix2StructImageOCRAPI/#geniusrise_ocr.ocr.pix2struct.api.Pix2StructImageOCRAPI.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
The TROCRImageOCR class performs OCR (Optical Character Recognition) on images using Microsoft's TROCR model. It expects the input.input_folder to contain the images for OCR and saves the OCR results as JSON files in output.output_folder.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/TROCRImageOCR/#geniusrise_ocr.ocr.trocr.bulk.TROCRImageOCR.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/TROCRImageOCR/#geniusrise_ocr.ocr.trocr.bulk.TROCRImageOCR.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
\ud83d\udcd6 Perform OCR on images in the input folder and save the OCR results as JSON files in the output folder.
This method iterates through each image file in input.input_folder, performs OCR using the TROCR model, and saves the OCR results as JSON files in output.output_folder.
Parameters:
Name Type Description Default kindstr
The kind of TROCR model to use. Default is \"printed\". Options are \"printed\" or \"handwritten\".
'printed'use_cudabool
Whether to use CUDA for model inference. Default is True.
True"},{"location":"ocr/TROCRImageOCRAPI/","title":"OCR API using trocr","text":"
The TROCRImageOCR class performs OCR (Optical Character Recognition) on images using Microsoft's TROCR model. The class exposes an API endpoint for OCR on single images. The endpoint is accessible at /api/v1/ocr. The API takes a POST request with a JSON payload containing a base64 encoded image under the key image_base64. It returns a JSON response containing the OCR result under the key ocr_text.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/TROCRImageOCRAPI/#geniusrise_ocr.ocr.trocr.api.TROCRImageOCRAPI.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/TROCRImageOCRAPI/#geniusrise_ocr.ocr.trocr.api.TROCRImageOCRAPI.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
The TrainImageClassifier class trains an image classifier using a ResNet-152 model. It assumes that the input.input_folder contains sub-folders named 'train' and 'test'. Each of these sub-folders should contain class-specific folders with images. The trained model is saved as 'model.pth' in output.output_folder.
Parameters:
Name Type Description Default inputBatchInput
Instance of BatchInput for reading data.
required outputBatchOutput
Instance of BatchOutput for saving data.
required stateState
Instance of State for maintaining state.
required **kwargs
Additional keyword arguments.
{}"},{"location":"ocr/TrainImageClassifier/#geniusrise_ocr.classification.train.TrainImageClassifier.__init__--command-line-invocation-with-geniusrise","title":"Command Line Invocation with geniusrise","text":"
"},{"location":"ocr/TrainImageClassifier/#geniusrise_ocr.classification.train.TrainImageClassifier.__init__--yaml-configuration-with-geniusrise","title":"YAML Configuration with geniusrise","text":"
\ud83d\udcd6 Train an image classifier using a ResNet-152 model.
Parameters:
Name Type Description Default num_classesint
Number of classes of the images.
4epochsint
Number of training epochs. Default is 10.
10batch_sizeint
Batch size for training. Default is 32.
32learning_ratefloat
Learning rate for the optimizer. Default is 0.001.
0.001use_cudabool
Whether to use CUDA for model training. Default is False.
False
This method trains a ResNet-152 model using the images in the 'train' and 'test' sub-folders of input.input_folder. Each of these sub-folders should contain class-specific folders with images. The trained model is saved as 'model.pth' in output.output_folder.
"},{"location":"text/api/base/","title":"Base Fine Tuner","text":"
Bases: TextBulk
A class representing a Hugging Face API for generating text using a pre-trained language model.
Attributes:
Name Type Description modelAny
The pre-trained language model.
tokenizerAny
The tokenizer used to preprocess input text.
model_namestr
The name of the pre-trained language model.
model_revisionOptional[str]
The revision of the pre-trained language model.
tokenizer_namestr
The name of the tokenizer used to preprocess input text.
tokenizer_revisionOptional[str]
The revision of the tokenizer used to preprocess input text.
model_classstr
The name of the class of the pre-trained language model.
tokenizer_classstr
The name of the class of the tokenizer used to preprocess input text.
use_cudabool
Whether to use a GPU for inference.
quantizationint
The level of quantization to use for the pre-trained language model.
precisionstr
The precision to use for the pre-trained language model.
device_mapstr | Dict | None
The mapping of devices to use for inference.
max_memoryDict[int, str]
The maximum memory to use for inference.
torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model.
model_argsAny
Additional arguments to pass to the pre-trained language model.
Methods
text(**kwargs: Any) -> Dict[str, Any]: Generates text based on the given prompt and decoding strategy.
TextClassificationAPI leveraging Hugging Face's transformers for text classification tasks. This API provides an interface to classify text into various categories like sentiment, topic, intent, etc.
Attributes:
Name Type Description modelAutoModelForSequenceClassification
A Hugging Face model for sequence classification.
tokenizerAutoTokenizer
A tokenizer for preprocessing text.
hf_pipelinePipeline
A Hugging Face pipeline for text classification.
Methods
classify(self): Classifies text using the model and tokenizer. classification_pipeline(self): Classifies text using the Hugging Face pipeline. initialize_pipeline(self): Lazy initialization of the classification pipeline.
Accepts text input and returns classification results using the Hugging Face pipeline.
This method uses the Hugging Face pipeline for efficient and robust text classification. It's suitable for various classification tasks such as sentiment analysis, topic classification, and intent recognition.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and the classification results.
Example CURL Request for text classification:
/usr/bin/curl -X POST localhost:3000/api/v1/classification_pipeline -H \"Content-Type: application/json\" -d '{\"text\": \"The movie was fantastic, with great acting and plot.\"}' | jq\n
Accepts text input and returns classification results. The method uses the model and tokenizer to classify the text and provide the likelihood of each class label.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and the classification scores for each label.
Example CURL Request for text classification:
/usr/bin/curl -X POST localhost:3000/api/v1/classify -H \"Content-Type: application/json\" -d '{\n \"text\": \"tata sons lost a major contract to its rival mahindra motors\"\n }' | jq\n
InstructionAPI is designed for generating text based on prompts using instruction-tuned language models. It serves as an interface to Hugging Face's pre-trained instruction-tuned models, providing a flexible API for various text generation tasks. It can be used in scenarios ranging from generating creative content to providing instructions or answers based on the prompts.
Attributes:
Name Type Description modelAny
The loaded instruction-tuned language model.
tokenizerAny
The tokenizer for processing text suitable for the model.
Methods
complete(**kwargs: Any) -> Dict[str, Any]: Generates text based on the given prompt and decoding strategy.
listen(**model_args: Any) -> None: Starts a server to listen for text generation requests.
Handles chat interaction using the Hugging Face pipeline. This method enables conversational text generation, simulating a chat-like interaction based on user and system prompts.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments containing 'user_prompt' and 'system_prompt'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the user prompt, system prompt, and chat interaction results.
Example CURL Request for chat interaction:
/usr/bin/curl -X POST localhost:3001/api/v1/chat -H \"Content-Type: application/json\" -d '{\n \"user_prompt\": \"What is the capital of France?\",\n \"system_prompt\": \"The capital of France is\"\n }' | jq\n
Handles POST requests to generate chat completions using the llama.cpp engine. This method accepts various parameters for customizing the chat completion request, including messages, sampling settings, and more.
Parameters:
Name Type Description Default messagesList[Dict[str, str]]
The chat messages for generating a response.
required functionsOptional[List[Dict]]
A list of functions to use for the chat completion (advanced usage).
required function_callOptional[Dict]
A function call to use for the chat completion (advanced usage).
required toolsOptional[List[Dict]]
A list of tools to use for the chat completion (advanced usage).
required tool_choiceOptional[Dict]
A tool choice option for the chat completion (advanced usage).
required temperaturefloat
The temperature to use for sampling, controlling randomness.
required top_pfloat
The nucleus sampling's top-p parameter, controlling diversity.
required top_kint
The top-k sampling parameter, limiting the token selection pool.
required min_pfloat
The minimum probability threshold for sampling.
required typical_pfloat
The typical-p parameter for locally typical sampling.
required streambool
Flag to stream the results.
required stopOptional[Union[str, List[str]]]
Tokens or sequences where generation should stop.
required seedOptional[int]
Seed for random number generation to ensure reproducibility.
required response_formatOptional[Dict]
Specifies the format of the generated response.
required max_tokensOptional[int]
Maximum number of tokens to generate.
required presence_penaltyfloat
Penalty for token presence to discourage repetition.
required frequency_penaltyfloat
Penalty for token frequency to discourage common tokens.
required repeat_penaltyfloat
Penalty applied to tokens that are repeated.
required tfs_zfloat
Tail-free sampling parameter to adjust the likelihood of tail tokens.
required mirostat_modeint
Mirostat sampling mode for dynamic adjustments.
required mirostat_taufloat
Tau parameter for mirostat sampling, controlling deviation.
required mirostat_etafloat
Eta parameter for mirostat sampling, controlling adjustment speed.
required modelOptional[str]
Specifies the model to use for generation.
required logits_processorOptional[List]
List of logits processors for advanced generation control.
required grammarOptional[Dict]
Specifies grammar rules for the generated text.
required logit_biasOptional[Dict[str, float]]
Adjustments to the logits of specified tokens.
required logprobsOptional[bool]
Whether to include log probabilities in the output.
required top_logprobsOptional[int]
Number of top log probabilities to include.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the chat completion response or an error message.
Example CURL Request:
curl -X POST \"http://localhost:3000/api/v1/chat_llama_cpp\" -H \"Content-Type: application/json\" -d '{\n \"messages\": [\n {\"role\": \"user\", \"content\": \"What is the capital of France?\"},\n {\"role\": \"system\", \"content\": \"The capital of France is\"}\n ],\n \"temperature\": 0.2,\n \"top_p\": 0.95,\n \"top_k\": 40,\n \"max_tokens\": 50,\n }'\n
Handles POST requests to generate chat completions using the VLLM (Versatile Language Learning Model) engine. This method accepts various parameters for customizing the chat completion request, including message content, generation settings, and more.
Parameters:
Name Type Description Default messagesList[Dict[str, str]]
The chat messages for generating a response. Each message should include a 'role' (either 'user' or 'system') and 'content'.
required temperaturefloat
The sampling temperature. Defaults to 0.7. Higher values generate more random completions.
required top_pfloat
The nucleus sampling probability. Defaults to 1.0. A smaller value leads to higher diversity.
required nint
The number of completions to generate. Defaults to 1.
required max_tokensint
The maximum number of tokens to generate. Controls the length of the generated response.
required stopUnion[str, List[str]]
Sequence(s) where the generation should stop. Can be a single string or a list of strings.
required streambool
Whether to stream the response. Streaming may be useful for long completions.
required presence_penaltyfloat
Adjusts the likelihood of tokens based on their presence in the conversation so far. Defaults to 0.0.
required frequency_penaltyfloat
Adjusts the likelihood of tokens based on their frequency in the conversation so far. Defaults to 0.0.
required logit_biasDict[str, float]
Adjustments to the logits of specified tokens, identified by token IDs as keys and adjustment values as values.
required userstr
An identifier for the user making the request. Can be used for logging or customization.
required best_ofint
Generates 'n' completions server-side and returns the best one. Higher values incur more computation cost.
required top_kint
Filters the generated tokens to the top-k tokens with the highest probabilities. Defaults to -1, which disables top-k filtering.
required ignore_eosbool
Whether to ignore the end-of-sentence token in generation. Useful for more fluid continuations.
required use_beam_searchbool
Whether to use beam search instead of sampling for generation. Beam search can produce more coherent results.
required stop_token_idsList[int]
List of token IDs that should cause generation to stop.
required skip_special_tokensbool
Whether to skip special tokens (like padding or end-of-sequence tokens) in the output.
required spaces_between_special_tokensbool
Whether to insert spaces between special tokens in the output.
required add_generation_promptbool
Whether to prepend the generation prompt to the output.
required echobool
Whether to include the input prompt in the output.
required repetition_penaltyfloat
Penalty applied to tokens that have been generated previously. Defaults to 1.0, which applies no penalty.
required min_pfloat
Sets a minimum threshold for token probabilities. Tokens with probabilities below this threshold are filtered out.
required include_stop_str_in_outputbool
Whether to include the stop string(s) in the output.
required length_penaltyfloat
Exponential penalty to the length for beam search. Only relevant if use_beam_search is True.
required
Dict[str, Any]: A dictionary with the chat completion response or an error message.
Example CURL Request:
curl -X POST \"http://localhost:3000/api/v1/chat_vllm\" -H \"Content-Type: application/json\" -d '{\n \"messages\": [\n {\"role\": \"user\", \"content\": \"Whats the weather like in London?\"}\n ],\n \"temperature\": 0.7,\n \"top_p\": 1.0,\n \"n\": 1,\n \"max_tokens\": 50,\n \"stream\": false,\n \"presence_penalty\": 0.0,\n \"frequency_penalty\": 0.0,\n \"logit_bias\": {},\n \"user\": \"example_user\"\n }'\n
This request asks the VLLM engine to generate a completion for the provided chat context, with specified generation settings."},{"location":"text/api/instruction_tuning/#geniusrise_text.instruction.api.InstructionAPI.complete","title":"complete(**kwargs)","text":"
Handles POST requests to generate text based on the given prompt and decoding strategy. It uses the pre-trained\n model specified in the setup to generate a completion for the input prompt.\n\n Args:\n **kwargs (Any): Arbitrary keyword arguments containing the 'prompt' and other parameters for text generation.\n\n Returns:\n Dict[str, Any]: A dictionary containing the original prompt and the generated completion.\n\n Example CURL Requests:\n ```bash\n /usr/bin/curl -X POST localhost:3001/api/v1/complete -H \"Content-Type: application/json\" -d '{\n \"prompt\": \"<|system|>\n
<|end|> <|user|> How do I sort a list in Python?<|end|> <|assistant|>\", \"decoding_strategy\": \"generate\", \"max_new_tokens\": 100, \"do_sample\": true, \"temperature\": 0.7, \"top_k\": 50, \"top_p\": 0.95 }' | jq ```
LanguageModelAPI is a class for interacting with pre-trained language models to generate text. It allows for customizable text generation via a CherryPy web server, handling requests and generating responses using a specified language model. This class is part of the GeniusRise ecosystem for facilitating NLP tasks.
Attributes:
Name Type Description modelAny
The loaded language model used for text generation.
tokenizerAny
The tokenizer corresponding to the language model, used for processing input text.
Methods
complete(**kwargs: Any) -> Dict[str, Any]: Generates text based on provided prompts and model parameters.
Handles POST requests to generate text based on a given prompt and model-specific parameters. This method is exposed as a web endpoint through CherryPy and returns a JSON response containing the original prompt, the generated text, and any additional returned information from the model.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments containing the prompt, and any additional parameters
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary with the original prompt, generated text, and other model-specific information.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/complete \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"prompt\": \"Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n### Instruction:\\nWrite a PRD for Oauth auth using keycloak\\n\\n### Response:\",\n \"decoding_strategy\": \"generate\",\n \"max_new_tokens\": 1024,\n \"do_sample\": true\n }' | jq\n
Handles POST requests to generate chat completions using the llama.cpp engine. This method accepts various parameters for customizing the chat completion request, including messages, sampling settings, and more.
Parameters:
Name Type Description Default prompt
The prompt to generate text from.
required suffix
A suffix to append to the generated text. If None, no suffix is appended.
required max_tokens
The maximum number of tokens to generate. If max_tokens <= 0 or None, the maximum number of tokens to generate is unlimited and depends on n_ctx.
required temperature
The temperature to use for sampling.
required top_p
The top-p value to use for nucleus sampling. Nucleus sampling described in academic paper \"The Curious Case of Neural Text Degeneration\" https://arxiv.org/abs/1904.09751
required min_p
The min-p value to use for minimum p sampling. Minimum P sampling as described in https://github.com/ggerganov/llama.cpp/pull/3841
required typical_p
The typical-p value to use for sampling. Locally Typical Sampling implementation described in the paper https://arxiv.org/abs/2202.00666.
required logprobs
The number of logprobs to return. If None, no logprobs are returned.
required echo
Whether to echo the prompt.
required stop
A list of strings to stop generation when encountered.
required frequency_penalty
The penalty to apply to tokens based on their frequency in the prompt.
required presence_penalty
The penalty to apply to tokens based on their presence in the prompt.
required repeat_penalty
The penalty to apply to repeated tokens.
required top_k
The top-k value to use for sampling. Top-K sampling described in academic paper \"The Curious Case of Neural Text Degeneration\" https://arxiv.org/abs/1904.09751
required stream
Whether to stream the results.
required seed
The seed to use for sampling.
required tfs_z
The tail-free sampling parameter. Tail Free Sampling described in https://www.trentonbricken.com/Tail-Free-Sampling/.
required mirostat_mode
The mirostat sampling mode.
required mirostat_tau
The target cross-entropy (or surprise) value you want to achieve for the generated text. A higher value corresponds to more surprising or less predictable text, while a lower value corresponds to less surprising or more predictable text.
required mirostat_eta
The learning rate used to update mu based on the error between the target and observed surprisal of the sampled word. A larger learning rate will cause mu to be updated more quickly, while a smaller learning rate will result in slower updates.
required model
The name to use for the model in the completion object.
required stopping_criteria
A list of stopping criteria to use.
required logits_processor
A list of logits processors to use.
required grammar
A grammar to use for constrained sampling.
required logit_bias
A logit bias to use.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the chat completion response or an error message.
Example CURL Request:
curl -X POST \"http://localhost:3001/api/v1/complete_llama_cpp\" -H \"Content-Type: application/json\" -d '{\n \"prompt\": \"Whats the weather like in London?\",\n \"temperature\": 0.7,\n \"top_p\": 0.95,\n \"top_k\": 40,\n \"max_tokens\": 50,\n \"repeat_penalty\": 1.1\n }'\n
Handles POST requests to generate chat completions using the VLLM (Versatile Language Learning Model) engine. This method accepts various parameters for customizing the chat completion request, including message content, generation settings, and more.
**kwargs (Any): Arbitrary keyword arguments. Expects data in JSON format containing any of the following keys:
messages (Union[str, List[Dict[str, str]]]): The messages for the chat context.
temperature (float, optional): The sampling temperature. Defaults to 0.7.
top_p (float, optional): The nucleus sampling probability. Defaults to 1.0.
n (int, optional): The number of completions to generate. Defaults to 1.
max_tokens (int, optional): The maximum number of tokens to generate.
stop (Union[str, List[str]], optional): Stop sequence to end generation.
stream (bool, optional): Whether to stream the response. Defaults to False.
presence_penalty (float, optional): The presence penalty. Defaults to 0.0.
frequency_penalty (float, optional): The frequency penalty. Defaults to 0.0.
logit_bias (Dict[str, float], optional): Adjustments to the logits of specified tokens.
user (str, optional): An identifier for the user making the request.
(Additional model-specific parameters)
Dict[str, Any]: A dictionary with the chat completion response or an error message.
Example CURL Request:
curl -v -X POST \"http://localhost:3000/api/v1/complete_vllm\" -H \"Content-Type: application/json\" -u \"user:password\" -d '{\n \"messages\": [\"Whats the weather like in London?\"],\n \"temperature\": 0.7,\n \"top_p\": 1.0,\n \"n\": 1,\n \"max_tokens\": 50,\n \"stream\": false,\n \"presence_penalty\": 0.0,\n \"frequency_penalty\": 0.0,\n \"logit_bias\": {},\n \"user\": \"example_user\"\n }'\n
This request asks the VLLM engine to generate a completion for the provided chat context, with specified generation settings."},{"location":"text/api/ner/","title":"Named Entity Recognition","text":"
Bases: TextAPI
NamedEntityRecognitionAPI serves a Named Entity Recognition (NER) model using the Hugging Face transformers library. It is designed to recognize and classify named entities in text into predefined categories such as the names of persons, organizations, locations, expressions of times, quantities, monetary values, percentages, etc.
Attributes:
Name Type Description modelAny
The loaded NER model, typically a Hugging Face transformer model specialized for token classification.
tokenizerAny
The tokenizer for preprocessing text compatible with the loaded model.
Recognizes named entities in the input text using the Hugging Face pipeline.
This method leverages a pre-trained NER model to identify and classify entities in text into categories such as names, organizations, locations, etc. It's suitable for processing various types of text content.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and a list of recognized entities.
Example CURL Request for NER:
curl -X POST localhost:3000/api/v1/ner_pipeline -H \"Content-Type: application/json\" -d '{\"text\": \"John Doe works at OpenAI in San Francisco.\"}' | jq\n
Endpoint for recognizing named entities in the input text using the loaded NER model.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' for the input text.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original input text and a list of recognized entities with their respective types.
Example CURL Requests:
curl -X POST localhost:3000/api/v1/recognize_entities \\\n-H \"Content-Type: application/json\" \\\n-d '{\"text\": \"John Doe works at OpenAI in San Francisco.\"}' | jq\n
curl -X POST localhost:3000/api/v1/recognize_entities \\\n-H \"Content-Type: application/json\" \\\n-d '{\"text\": \"Alice is going to visit the Eiffel Tower in Paris next summer.\"}' | jq\n
"},{"location":"text/api/nli/","title":"Natural Language Inference","text":"
Bases: TextAPI
Represents a Natural Language Inference (NLI) API leveraging Hugging Face's transformer models. This class is capable of handling various NLI tasks such as entailment, classification, similarity checking, and more. Utilizes CherryPy for exposing API endpoints that can be interacted with via standard HTTP requests.
Attributes:
Name Type Description modelAutoModelForSequenceClassification
The loaded Hugging Face model for sequence classification tasks.
tokenizerAutoTokenizer
The tokenizer corresponding to the model, used for processing input text.
CLI Usage Example: For interacting with the NLI API, you would typically start the server using a command similar to one listed in the provided examples. After the server is running, you can use CURL commands to interact with the different endpoints.
Endpoint for classifying the input text into one of the provided candidate labels using zero-shot classification.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'text' and 'candidate_labels'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the input text, candidate labels, and classification scores.
Example CURL Request:
curl -X POST localhost:3000/api/v1/classify \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text\": \"The new movie is a thrilling adventure in space\",\n \"candidate_labels\": [\"entertainment\", \"politics\", \"business\"]\n }'\n
Detects the intent of the input text from a list of possible intents.
Parameters:
Name Type Description Default textstr
The input text.
required intentsList[str]
A list of possible intents.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the input text and detected intent with its score.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/detect_intent \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"intents\": [\"teach\",\"sell\",\"note\",\"advertise\",\"promote\"]\n }' | jq\n
Endpoint for evaluating the entailment relationship between a premise and a hypothesis. It returns the relationship scores across possible labels like entailment, contradiction, and neutral.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'premise' and 'hypothesis'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the premise, hypothesis, and their relationship scores.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/entailment \\\n-H \"Content-Type: application/json\" \\\\\\\n-d '{\n \"premise\": \"This a very good entry level smartphone, battery last 2-3 days after fully charged when connected to the internet. No memory lag issue when playing simple hidden object games. Performance is beyond my expectation, i bought it with a good bargain, couldnt ask for more!\",\n \"hypothesis\": \"the phone has an awesome battery life\"\n }' | jq\n
Performs fact checking on a statement given a context.
Parameters:
Name Type Description Default contextstr
The context or background information.
required statementstr
The statement to fact check.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing fact checking scores.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/fact_checking \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"context\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"statement\": \"The author is looking for a home loan\"\n }' | jq\n
Performs question answering for multiple choice questions.
Parameters:
Name Type Description Default questionstr
The question text.
required choicesList[str]
A list of possible answers.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the scores for each answer choice.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/question_answering \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"question\": \"[ML-1T-2] is the dimensional formula of\",\n \"choices\": [\"force\", \"coefficient of friction\", \"modulus of elasticity\", \"energy\"]\n }' | jq\n
Evaluates the textual similarity between two texts.
Parameters:
Name Type Description Default text1str
The first text.
required text2str
The second text.
required
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing similarity score.
Example CURL Request:
/usr/bin/curl -X POST localhost:3000/api/v1/textual_similarity \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text1\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"text2\": \"There is something magical about training neural networks. Their simplicity coupled with their power is astonishing.\"\n }' | jq\n
Performs zero-shot classification using the Hugging Face pipeline. It allows classification of text without explicitly provided labels.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'premise' and 'hypothesis'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the premise, hypothesis, and their classification scores.
Example CURL Request for zero-shot classification:
curl -X POST localhost:3000/api/v1/zero_shot_classification -H \"Content-Type: application/json\" -d '{\n \"premise\": \"A new study shows that the Mediterranean diet is good for heart health.\",\n \"hypothesis\": \"The study is related to diet and health.\"\n }' | jq\n
A class for handling different types of QA models, including traditional QA, TAPAS (Table-based QA), and TAPEX. It utilizes the Hugging Face transformers library to provide state-of-the-art question answering capabilities across various formats of data including plain text and tabular data.
Attributes:
Name Type Description modelAutoModelForQuestionAnswering | AutoModelForTableQuestionAnswering
The pre-trained QA model (traditional, TAPAS, or TAPEX).
tokenizerAutoTokenizer
The tokenizer used to preprocess input text.
Methods
answer(self, **kwargs: Any) -> Dict[str, Any]: Answers questions based on the provided context (text or table).
Answers questions based on the provided context (text or table). It adapts to the model type (traditional, TAPAS, TAPEX) and provides answers accordingly.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing the 'question' and 'data' (context or table).
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the question, context/table, and answer(s).
Example CURL Request for Text-based QA:
curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-d '{\"question\": \"What is the capital of France?\", \"data\": \"France is a country in Europe. Its capital is Paris.\"}'\n
Example CURL Requests:
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"data\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"question\": \"What is the common wisdom about RNNs?\"\n }' | jq\n
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"data\": [\n {\"Name\": \"Alice\", \"Age\": \"30\"},\n {\"Name\": \"Bob\", \"Age\": \"25\"}\n ],\n \"question\": \"what is their total age?\"\n}\n' | jq\n
/usr/bin/curl -X POST localhost:3000/api/v1/answer \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"data\": {\"Actors\": [\"Brad Pitt\", \"Leonardo Di Caprio\", \"George Clooney\"], \"Number of movies\": [\"87\", \"53\", \"69\"]},\n \"question\": \"how many movies does Leonardo Di Caprio have?\"\n}\n' | jq\n
Answers questions using the Hugging Face pipeline based on the provided context.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, typically containing 'question' and 'data'.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the question, context, and the answer.
Example CURL Request for QA:
curl -X POST localhost:3000/api/v1/answer_pipeline -H \"Content-Type: application/json\" -d '{\"question\": \"Who is the CEO of Tesla?\", \"data\": \"Elon Musk is the CEO of Tesla.\"}'\n
A class for serving a Hugging Face-based summarization model. This API provides an interface to submit text and receive a summarized version, utilizing state-of-the-art machine learning models for text summarization.
Attributes:
Name Type Description modelAutoModelForSeq2SeqLM
The loaded Hugging Face model for summarization.
tokenizerAutoTokenizer
The tokenizer for preprocessing text.
Methods
summarize(self, **kwargs: Any) -> Dict[str, Any]: Summarizes the input text based on the given parameters.
Summarizes the input text based on the given parameters using a machine learning model. The method accepts parameters via a POST request and returns the summarized text.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments. Expected to receive these from the POST request's JSON body.
{}
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the input text and its summary.
Example CURL Requests:
/usr/bin/curl -X POST localhost:3000/api/v1/summarize \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"decoding_strategy\": \"generate\",\n \"bos_token_id\": 0,\n \"decoder_start_token_id\": 2,\n \"early_stopping\": true,\n \"eos_token_id\": 2,\n \"forced_bos_token_id\": 0,\n \"forced_eos_token_id\": 2,\n \"length_penalty\": 2.0,\n \"max_length\": 142,\n \"min_length\": 56,\n \"no_repeat_ngram_size\": 3,\n \"num_beams\": 4,\n \"pad_token_id\": 1,\n \"do_sample\": false\n }' | jq\n
/usr/bin/curl -X POST localhost:3000/api/v1/summarize \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"text\": \"Theres something magical about Recurrent Neural Networks (RNNs). I still remember when I trained my first recurrent network for Image Captioning. Within a few dozen minutes of training my first baby model (with rather arbitrarily-chosen hyperparameters) started to generate very nice looking descriptions of images that were on the edge of making sense. Sometimes the ratio of how simple your model is to the quality of the results you get out of it blows past your expectations, and this was one of those times. What made this result so shocking at the time was that the common wisdom was that RNNs were supposed to be difficult to train (with more experience Ive in fact reached the opposite conclusion). Fast forward about a year: Im training RNNs all the time and Ive witnessed their power and robustness many times, and yet their magical outputs still find ways of amusing me.\",\n \"decoding_strategy\": \"generate\",\n \"early_stopping\": true,\n \"length_penalty\": 2.0,\n \"max_length\": 142,\n \"min_length\": 56,\n \"no_repeat_ngram_size\": 3,\n \"num_beams\": 4\n }' | jq\n
Summarizes the input text using the Hugging Face pipeline based on given parameters.
Parameters:
Name Type Description Default **kwargsAny
Keyword arguments containing parameters for summarization.
{}
Returns:
Type Description Dict[str, Any]
A dictionary containing the input text and its summary.
Example CURL Request for summarization: curl -X POST localhost:3000/api/v1/summarize_pipeline -H \"Content-Type: application/json\" -d '{\"text\": \"Your long text here\"}'
A class for serving a Hugging Face-based translation model as a web API. This API allows users to submit text for translation and receive translated text in the specified target language using advanced machine learning models.
Parameters:
Name Type Description Default inputBatchInput
Configurations and data inputs for the batch process.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the translation task.
required **kwargsAny
Additional keyword arguments for extended configurations.
Translates text to a specified target language using the underlying Hugging Face model.
This endpoint accepts JSON data with the text and language details, processes it through the machine learning model, and returns the translated text.
Parameters:
Name Type Description Default **kwargsAny
Arbitrary keyword arguments, usually empty as parameters are in the POST body.
{} POST body parameters
text (str): The text to be translated. decoding_strategy (str): Strategy to use for decoding text; e.g., 'beam_search', 'greedy'. Default is 'generate'. source_lang (str): Source language code. target_lang (str): Target language code. Default is 'en'. additional_params (dict): Other model-specific parameters for translation.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary with the original text, target language, and translated text.
Endpoint for translating text using a pre-initialized Hugging Face translation pipeline. This method is designed to handle translation requests more efficiently by utilizing a preloaded model and tokenizer, reducing the overhead of loading these components for each request.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the original text, source language, target language, and the translated text.
"},{"location":"text/bulk/base/","title":"Base Fine Tuner","text":"
Bases: Bolt
TextBulk is a foundational class for enabling bulk processing of text with various generation models. It primarily focuses on using Hugging Face models to provide a robust and efficient framework for large-scale text generation tasks. The class supports various decoding strategies to generate text that can be tailored to specific needs or preferences.
Attributes:
Name Type Description modelAutoModelForCausalLM
The language model for text generation.
tokenizerAutoTokenizer
The tokenizer for preparing input data for the model.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for the batch process.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the Bolt.
required **kwargs
Arbitrary keyword arguments for extended configurations.
{} Methods
text(**kwargs: Any) -> Dict[str, Any]: Provides an API endpoint for text generation functionality. Accepts various parameters for customizing the text generation process.
generate(prompt: str, decoding_strategy: str = \"generate\", **generation_params: Any) -> dict: Generates text based on the provided prompt and parameters. Supports multiple decoding strategies for diverse applications.
The class serves as a versatile tool for text generation, supporting various models and configurations. It can be extended or used as is for efficient text generation tasks.
TextClassificationBulk is designed to handle bulk text classification tasks using Hugging Face models efficiently and effectively. It allows for processing large datasets, utilizing state-of-the-art machine learning models to provide accurate classification of text data into predefined labels.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for the batch process.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the classification task.
required **kwargs
Arbitrary keyword arguments for extended configurations.
Perform bulk classification using the specified model and tokenizer. This method handles the entire classification process including loading the model, processing input data, predicting classifications, and saving the results.
Parameters:
Name Type Description Default model_namestr
Name or path of the model.
required model_classstr
Class name of the model (default \"AutoModelForSequenceClassification\").
The maximum length for tokenization. Defaults to 512.
512
Returns:
Name Type Description DatasetOptional[Dataset]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/bulk/classification/#geniusrise_text.classification.bulk.TextClassificationBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/classification/#geniusrise_text.classification.bulk.TextClassificationBulk.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
InstructionBulk is a class designed to perform bulk text generation tasks using Hugging Face's instruction-tuned language models. It is optimized for large-scale text generation, providing an efficient interface to use state-of-the-art machine learning models for generating text based on a set of instructions or prompts.
Attributes:
Name Type Description modelAny
The loaded, pre-trained instruction-tuned language model.
tokenizerAny
The tokenizer for processing text compatible with the model.
Methods
load_dataset(dataset_path: str, max_length: int = 1024, **kwargs) -> Optional[Dataset]: Loads a dataset for text generation tasks from the specified directory.
perform(model_name: str, **kwargs: Any) -> None: Performs bulk text generation using the specified model and tokenizer.
Loads a dataset from the specified path. This method supports various data formats including JSON, CSV, Parquet, and others. It's designed to facilitate the bulk processing of text data for generation tasks.
Parameters:
Name Type Description Default dataset_pathstr
Path to the directory containing the dataset files.
required max_lengthint
Maximum token length for text processing (default is 1024).
1024**kwargs
Additional keyword arguments for dataset loading.
{}
Returns:
Type Description Optional[Dataset]
Optional[Dataset]: A Dataset object if loading is successful; otherwise, None.
Raises:
Type Description Exception
If an error occurs during dataset loading.
"},{"location":"text/bulk/instruction_tuning/#geniusrise_text.instruction.bulk.InstructionBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/instruction_tuning/#geniusrise_text.instruction.bulk.InstructionBulk.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
Performs text generation in bulk using a specified instruction-tuned model. This method handles the entire process, including model loading, prompt processing, text generation, and saving the results.
Parameters:
Name Type Description Default model_namestr
The name or path of the instruction-tuned model.
required model_classstr
The class of the language model. Defaults to \"AutoModelForCausalLM\".
'AutoModelForCausalLM'tokenizer_classstr
The class of the tokenizer. Defaults to \"AutoTokenizer\".
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference. Defaults to False.
Falseprecisionstr
Precision for model computation. Defaults to \"float16\".
'float16'quantizationint
Level of quantization for optimizing model size and speed. Defaults to 0.
0device_mapstr | Dict | None
Specific device to use for computation. Defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for devices. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization. Defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization. Defaults to False.
Falsedecoding_strategystr
Strategy for decoding the completion. Defaults to \"generate\".
'generate'**kwargsAny
Configuration and additional arguments for text generation such as model class, tokenizer class, precision, device map, and other generation-related parameters.
{} Note
Additional arguments are passed directly to the model and tokenizer initialization and the generation method.
Performs bulk text generation using the LLaMA model with llama.cpp backend. This method handles the entire process, including model loading, prompt processing, text generation, and saving the results.
Parameters:
Name Type Description Default modelstr
Path or identifier for the LLaMA model.
required filenameOptional[str]
Optional filename or glob pattern to match the model file.
Performs bulk text generation using the Versatile Language Learning Model (VLLM) with specified parameters for fine-tuning model behavior, including quantization and parallel processing settings. This method is designed to process large datasets efficiently by leveraging VLLM capabilities for generating high-quality text completions based on provided prompts.
Parameters:
Name Type Description Default model_namestr
The name or path of the VLLM model to use for text generation.
required use_cudabool
Flag indicating whether to use CUDA for GPU acceleration.
Falseprecisionstr
Precision of computations, can be \"float16\", \"bfloat16\", etc.
'float16'quantizationint
Level of quantization for model weights, 0 for none.
0device_mapstr | Dict | None
Specific device(s) to use for model inference.
'auto'vllm_tokenizer_modestr
Mode of the tokenizer (\"auto\", \"fast\", or \"slow\").
'auto'vllm_download_dirOptional[str]
Directory to download and load the model and tokenizer.
Nonevllm_load_formatstr
Format to load the model, e.g., \"auto\", \"pt\".
'auto'vllm_seedint
Seed for random number generation.
42vllm_max_model_lenint
Maximum sequence length the model can handle.
1024vllm_enforce_eagerbool
Enforce eager execution instead of using optimization techniques.
Disable custom all-reduce kernel and fall back to NCCL.
Falsevllm_max_num_batched_tokensOptional[int]
Maximum number of tokens to be processed in a single iteration.
Nonevllm_max_num_seqsint
Maximum number of sequences to be processed in a single iteration.
64vllm_max_paddingsint
Maximum number of paddings to be added to a batch.
512vllm_max_lora_rankOptional[int]
Maximum rank for LoRA adjustments.
Nonevllm_max_lorasOptional[int]
Maximum number of LoRA adjustments.
Nonevllm_max_cpu_lorasOptional[int]
Maximum number of LoRA adjustments stored on CPU.
Nonevllm_lora_extra_vocab_sizeint
Additional vocabulary size for LoRA.
0vllm_placement_groupOptional[dict]
Ray placement group for distributed execution.
Nonevllm_log_statsbool
Whether to log statistics during model operation.
Falsenotification_emailOptional[str]
Email to send notifications upon completion.
Nonebatch_sizeint
Number of prompts to process in each batch for efficient memory usage.
32**kwargsAny
Additional keyword arguments for generation settings like temperature, top_p, etc.
{}
This method automates the loading of large datasets, generation of text completions, and saving results, facilitating efficient and scalable text generation tasks.
LanguageModelBulk is designed for large-scale text generation using Hugging Face language models in a bulk processing manner. It's particularly useful for tasks such as bulk content creation, summarization, or any other scenario where large datasets need to be processed with a language model.
Attributes:
Name Type Description modelAny
The loaded language model used for text generation.
tokenizerAny
The tokenizer corresponding to the language model, used for processing input text.
Parameters:
Name Type Description Default inputBatchInput
Configuration for the input data.
required outputBatchOutput
Configuration for the output data.
required stateState
State management for the API.
required **kwargsAny
Arbitrary keyword arguments for extended functionality.
Performs text completion on the loaded dataset using the specified model and tokenizer. The method handles the entire process, including model loading, text generation, and saving the results.
Parameters:
Name Type Description Default model_namestr
The name of the language model to use for text completion.
required model_classstr
The class of the language model. Defaults to \"AutoModelForCausalLM\".
'AutoModelForCausalLM'tokenizer_classstr
The class of the tokenizer. Defaults to \"AutoTokenizer\".
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference. Defaults to False.
Falseprecisionstr
Precision for model computation. Defaults to \"float16\".
'float16'quantizationint
Level of quantization for optimizing model size and speed. Defaults to 0.
0device_mapstr | Dict | None
Specific device to use for computation. Defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for devices. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization. Defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization. Defaults to False.
Falsedecoding_strategystr
Strategy for decoding the completion. Defaults to \"generate\".
Performs bulk text generation using the LLaMA model with llama.cpp backend. This method handles the entire process, including model loading, prompt processing, text generation, and saving the results.
Parameters:
Name Type Description Default modelstr
Path or identifier for the LLaMA model.
required filenameOptional[str]
Optional filename or glob pattern to match the model file.
Performs bulk text generation using the Versatile Language Learning Model (VLLM) with specified parameters for fine-tuning model behavior, including quantization and parallel processing settings. This method is designed to process large datasets efficiently by leveraging VLLM capabilities for generating high-quality text completions based on provided prompts.
Parameters:
Name Type Description Default model_namestr
The name or path of the VLLM model to use for text generation.
required use_cudabool
Flag indicating whether to use CUDA for GPU acceleration.
Falseprecisionstr
Precision of computations, can be \"float16\", \"bfloat16\", etc.
'float16'quantizationint
Level of quantization for model weights, 0 for none.
0device_mapstr | Dict | None
Specific device(s) to use for model inference.
'auto'vllm_tokenizer_modestr
Mode of the tokenizer (\"auto\", \"fast\", or \"slow\").
'auto'vllm_download_dirOptional[str]
Directory to download and load the model and tokenizer.
Nonevllm_load_formatstr
Format to load the model, e.g., \"auto\", \"pt\".
'auto'vllm_seedint
Seed for random number generation.
42vllm_max_model_lenint
Maximum sequence length the model can handle.
1024vllm_enforce_eagerbool
Enforce eager execution instead of using optimization techniques.
Disable custom all-reduce kernel and fall back to NCCL.
Falsevllm_max_num_batched_tokensOptional[int]
Maximum number of tokens to be processed in a single iteration.
Nonevllm_max_num_seqsint
Maximum number of sequences to be processed in a single iteration.
64vllm_max_paddingsint
Maximum number of paddings to be added to a batch.
512vllm_max_lora_rankOptional[int]
Maximum rank for LoRA adjustments.
Nonevllm_max_lorasOptional[int]
Maximum number of LoRA adjustments.
Nonevllm_max_cpu_lorasOptional[int]
Maximum number of LoRA adjustments stored on CPU.
Nonevllm_lora_extra_vocab_sizeint
Additional vocabulary size for LoRA.
0vllm_placement_groupOptional[dict]
Ray placement group for distributed execution.
Nonevllm_log_statsbool
Whether to log statistics during model operation.
Falsenotification_emailOptional[str]
Email to send notifications upon completion.
Nonebatch_sizeint
Number of prompts to process in each batch for efficient memory usage.
32**kwargsAny
Additional keyword arguments for generation settings like temperature, top_p, etc.
{}
This method automates the loading of large datasets, generation of text completions, and saving results, facilitating efficient and scalable text generation tasks.
The maximum length for tokenization. Defaults to 512.
512**kwargs
Additional keyword arguments to pass to the underlying dataset loading functions.
{}
Returns:
Name Type Description DatasetOptional[Dataset]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/bulk/language_model/#geniusrise_text.language_model.bulk.LanguageModelBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/language_model/#geniusrise_text.language_model.bulk.LanguageModelBulk.load_dataset--dataset-files-saved-by-hugging-face-datasets-library","title":"Dataset files saved by Hugging Face datasets library","text":"
The directory should contain 'dataset_info.json' and other related files.
NamedEntityRecognitionBulk is a class designed for bulk processing of Named Entity Recognition (NER) tasks. It leverages state-of-the-art NER models from Hugging Face's transformers library to identify and classify entities such as person names, locations, organizations, and other types of entities from a large corpus of text.
This class provides functionalities to load large datasets, configure NER models, and perform entity recognition in bulk, making it suitable for processing large volumes of text data efficiently.
Attributes:
Name Type Description modelAny
The NER model loaded for entity recognition tasks.
tokenizerAny
The tokenizer used for text pre-processing in alignment with the model.
Initializes the NamedEntityRecognitionBulk class with specified input, output, and state configurations. Sets up the NER model and tokenizer for bulk entity recognition tasks.
Parameters:
Name Type Description Default inputBatchInput
The input data configuration.
required outputBatchOutput
The output data configuration.
required stateState
The state management for the API.
required **kwargsAny
Additional keyword arguments for extended functionality.
Loads a dataset from the specified directory path. The method supports various data formats and structures, ensuring that the dataset is properly formatted for NER tasks.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required **kwargsAny
Additional keyword arguments to handle specific dataset loading scenarios.
{}
Returns:
Type Description Optional[Dataset]
Optional[Dataset]: The loaded dataset or None if an error occurs during loading.
"},{"location":"text/bulk/ner/#geniusrise_text.ner.bulk.NamedEntityRecognitionBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/ner/#geniusrise_text.ner.bulk.NamedEntityRecognitionBulk.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Performs bulk named entity recognition on the loaded dataset. The method processes the text in batches, applying the NER model to recognize entities.
Parameters:
Name Type Description Default model_namestr
The name or path of the NER model.
required max_lengthint
The maximum sequence length for the tokenizer.
512model_classstr
The class of the model, defaults to \"AutoModelForTokenClassification\".
'AutoModelForSeq2SeqLM'tokenizer_classstr
The class of the tokenizer, defaults to \"AutoTokenizer\".
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference, defaults to False.
Falseprecisionstr
Model computation precision, defaults to \"float16\".
'float16'quantizationint
Level of quantization for model size and speed optimization, defaults to 0.
0device_mapstr | Dict | None
Specific device configuration for computation, defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for the devices.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization, defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization, defaults to False.
Falsebatch_sizeint
Number of documents to process simultaneously, defaults to 32.
32**kwargsAny
Arbitrary keyword arguments for additional configuration.
{}
Returns:
Name Type Description NoneNone
The method processes the dataset and saves the predictions without returning any value.
"},{"location":"text/bulk/nli/","title":"Natural Language Inference","text":"
Bases: TextBulk
The NLIBulk class provides functionality for large-scale natural language inference (NLI) processing using Hugging Face transformers. It allows users to load datasets, configure models, and perform inference on batches of premise-hypothesis pairs.
Attributes:
Name Type Description inputBatchInput
Configuration and data inputs for the batch process.
Performs NLI inference on a loaded dataset using the specified model. The method processes the data in batches and saves the results to the configured output path.
Parameters:
Name Type Description Default model_namestr
Name or path of the NLI model.
required max_lengthint
Maximum length of the sequences for tokenization purposes. Defaults to 512.
512model_classstr
Class name of the model (e.g., \"AutoModelForSequenceClassification\"). Defaults to \"AutoModelForSeq2SeqLM\".
'AutoModelForSeq2SeqLM'tokenizer_classstr
Class name of the tokenizer (e.g., \"AutoTokenizer\"). Defaults to \"AutoTokenizer\".
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference. Defaults to False.
Falseprecisionstr
Precision for model computation (e.g., \"float16\"). Defaults to \"float16\".
'float16'quantizationint
Level of quantization for optimizing model size and speed. Defaults to 0.
0device_mapstr | Dict | None
Specific device to use for computation. Defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for devices. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization. Defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization. Defaults to False.
Falsebatch_sizeint
Number of premise-hypothesis pairs to process simultaneously. Defaults to 32.
32**kwargsAny
Arbitrary keyword arguments for model and generation configurations.
Load a commonsense reasoning dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory or file.
required max_lengthint
Maximum length of text sequences for tokenization purposes. Defaults to 512.
512**kwargs
Additional keyword arguments.
{}
Returns:
Name Type Description DatasetOptional[Dataset]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/bulk/nli/#geniusrise_text.nli.bulk.NLIBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/nli/#geniusrise_text.nli.bulk.NLIBulk.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
QABulk is a class designed for managing bulk question-answering tasks using Hugging Face models. It is capable of handling both traditional text-based QA and table-based QA (using TAPAS and TAPEX models), providing a versatile solution for automated question answering at scale.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for batch processing.
required outputBatchOutput
Configurations for output data handling.
required stateState
State management for the bulk QA task.
required **kwargs
Arbitrary keyword arguments for extended functionality.
Perform bulk question-answering using the specified model and tokenizer. This method can handle various types of QA models including traditional, TAPAS, and TAPEX.
Parameters:
Name Type Description Default model_namestr
Name or path of the question-answering model.
required model_classstr
Class name of the model (e.g., \"AutoModelForQuestionAnswering\").
'AutoModelForQuestionAnswering'tokenizer_classstr
Class name of the tokenizer (e.g., \"AutoTokenizer\").
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference. Defaults to False.
Falseprecisionstr
Precision for model computation. Defaults to \"float16\".
'float16'quantizationint
Level of quantization for optimizing model size and speed. Defaults to 0.
0device_mapstr | Dict | None
Specific device to use for computation. Defaults to \"auto\".
'auto'max_memoryDict
Maximum memory configuration for devices. Defaults to {0: \"24GB\"}.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization. Defaults to False.
Falseflash_attentionbool
Whether to use flash attention optimization. Defaults to False.
Falsebatch_sizeint
Number of questions to process simultaneously. Defaults to 32.
32**kwargsAny
Arbitrary keyword arguments for model and generation configurations.
{} Processing
The method processes the data in batches, utilizing the appropriate model based on the model name and generating answers for the questions provided in the dataset.
"},{"location":"text/bulk/question_answering/#geniusrise_text.qa.bulk.QABulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/question_answering/#geniusrise_text.qa.bulk.QABulk.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
SummarizationBulk is a class for managing bulk text summarization tasks using Hugging Face models. It is designed to handle large-scale summarization tasks efficiently and effectively, utilizing state-of-the-art machine learning models to provide high-quality summaries.
The class provides methods to load datasets, configure summarization models, and execute bulk summarization tasks.
"},{"location":"text/bulk/summarization/#geniusrise_text.summarization.bulk.SummarizationBulk.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/bulk/summarization/#geniusrise_text.summarization.bulk.SummarizationBulk.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
Perform bulk summarization using the specified model and tokenizer. This method handles the entire summarization process including loading the model, processing input data, generating summarization, and saving the results.
Parameters:
Name Type Description Default model_namestr
Name or path of the translation model.
required originstr
Source language ISO code.
required targetstr
Target language ISO code.
required max_lengthint
Maximum length of the tokens (default 512).
512model_classstr
Class name of the model (default \"AutoModelForSeq2SeqLM\").
'AutoModelForSeq2SeqLM'tokenizer_classstr
Class name of the tokenizer (default \"AutoTokenizer\").
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference (default False).
Falseprecisionstr
Precision for model computation (default \"float16\").
'float16'quantizationint
Level of quantization for optimizing model size and speed (default 0).
0device_mapstr | Dict | None
Specific device to use for computation (default \"auto\").
'auto'max_memoryDict
Maximum memory configuration for devices.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization (default False).
Falseflash_attentionbool
Whether to use flash attention optimization (default False).
Falsebatch_sizeint
Number of translations to process simultaneously (default 32).
32max_lengthint
Maximum lenght of the summary to be generated (default 512).
512**kwargsAny
Arbitrary keyword arguments for model and generation configurations.
TranslationBulk is a class for managing bulk translations using Hugging Face models. It is designed to handle large-scale translation tasks efficiently and effectively, using state-of-the-art machine learning models to provide high-quality translations for various language pairs.
This class provides methods for loading datasets, configuring translation models, and executing bulk translation tasks.
Parameters:
Name Type Description Default inputBatchInput
Configuration and data inputs for batch processing.
required outputBatchOutput
Configuration for output data handling.
required stateState
State management for translation tasks.
required **kwargs
Arbitrary keyword arguments for extended functionality.
"},{"location":"text/bulk/translation/#geniusrise_text.translation.bulk.TranslationBulk.load_dataset--supported-data-formats-and-structures-for-translation-tasks","title":"Supported Data Formats and Structures for Translation Tasks:","text":"
Note: All examples are assuming the source as \"en\", refer to the specific model for this parameter.
Perform bulk translation using the specified model and tokenizer. This method handles the entire translation process including loading the model, processing input data, generating translations, and saving the results.
Parameters:
Name Type Description Default model_namestr
Name or path of the translation model.
required originstr
Source language ISO code.
required targetstr
Target language ISO code.
required max_lengthint
Maximum length of the tokens (default 512).
512model_classstr
Class name of the model (default \"AutoModelForSeq2SeqLM\").
'AutoModelForSeq2SeqLM'tokenizer_classstr
Class name of the tokenizer (default \"AutoTokenizer\").
'AutoTokenizer'use_cudabool
Whether to use CUDA for model inference (default False).
Falseprecisionstr
Precision for model computation (default \"float16\").
'float16'quantizationint
Level of quantization for optimizing model size and speed (default 0).
0device_mapstr | Dict | None
Specific device to use for computation (default \"auto\").
'auto'max_memoryDict
Maximum memory configuration for devices.
{0: '24GB'}torchscriptbool
Whether to use a TorchScript-optimized version of the pre-trained language model. Defaults to False.
Falsecompilebool
Whether to compile the model before fine-tuning. Defaults to True.
Falseawq_enabledbool
Whether to enable AWQ optimization (default False).
Falseflash_attentionbool
Whether to use flash attention optimization (default False).
Falsebatch_sizeint
Number of translations to process simultaneously (default 32).
32**kwargsAny
Arbitrary keyword arguments for model and generation configurations.
{}"},{"location":"text/fine_tune/base/","title":"Base Fine Tuner","text":"
Bases: Bolt
A bolt for fine-tuning Hugging Face models.
This bolt uses the Hugging Face Transformers library to fine-tune a pre-trained model. It uses the Trainer class from the Transformers library to handle the training.
A bolt for fine-tuning Hugging Face models for text classification tasks.
This class extends the TextFineTuner and specializes in fine-tuning models for text classification. It provides additional functionalities for loading and preprocessing text classification datasets in various formats.
The maximum length for tokenization. Defaults to 512.
512
Returns:
Name Type Description DatasetOptional[Dataset]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/classification/#geniusrise_text.classification.fine_tune.TextClassificationFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/classification/#geniusrise_text.classification.fine_tune.TextClassificationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"label\": \"The label\"}\n
A bolt for fine-tuning Hugging Face models on instruction tuning tasks.
This class inherits from TextFineTuner and specializes in fine-tuning models for instruction-based tasks. It provides additional methods for loading and preparing datasets in various formats, as well as computing custom metrics.
Compute evaluation metrics for the model's predictions.
This method takes the model's predictions and ground truth labels, converts them to text, and then computes the BLEU score for evaluation.
Parameters:
Name Type Description Default eval_predEvalPrediction
A named tuple containing predictions and label_ids. - predictions: The logits predicted by the model of shape (batch_size, sequence_length, num_classes). - label_ids: The ground truth labels of shape (batch_size, sequence_length).
required
Returns:
Type Description Optional[Dict[str, float]]
Optional[Dict[str, float]]: A dictionary containing the BLEU score. Returns None if an exception occurs.
Load an instruction tuning dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required max_lengthint
The maximum length for tokenization. Defaults to 512.
512
Returns:
Name Type Description DatasetUnion[Dataset, Dict]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/instruction_tuning/#geniusrise_text.instruction.fine_tune.InstructionFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/instruction_tuning/#geniusrise_text.instruction.fine_tune.InstructionFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
Compute evaluation metrics for the model's predictions.
This method takes the model's predictions and ground truth labels, converts them to text, and then computes the BLEU score for evaluation.
Parameters:
Name Type Description Default eval_predEvalPrediction
A named tuple containing predictions and label_ids. - predictions: The logits predicted by the model of shape (batch_size, sequence_length, num_classes). - label_ids: The ground truth labels of shape (batch_size, sequence_length).
required
Returns:
Type Description Optional[Dict[str, float]]
Optional[Dict[str, float]]: A dictionary containing the BLEU score. Returns None if an exception occurs.
Load a language modeling dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required maskedbool
Whether to use masked language modeling. Defaults to True.
Falsemax_lengthint
The maximum length for tokenization. Defaults to 512.
512
Returns:
Name Type Description Dataset
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/language_model/#geniusrise_text.language_model.fine_tune.LanguageModelFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/language_model/#geniusrise_text.language_model.fine_tune.LanguageModelFineTuner.load_dataset--dataset-files-saved-by-hugging-face-datasets-library","title":"Dataset files saved by Hugging Face datasets library","text":"
The directory should contain 'dataset_info.json' and other related files.
Load a named entity recognition dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required label_listList[str]
The list of labels for named entity recognition. Defaults to [].
[]
Returns:
Name Type Description DatasetDictUnion[Dataset, DatasetDict, None]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/ner/#geniusrise_text.ner.fine_tune.NamedEntityRecognitionFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/ner/#geniusrise_text.ner.fine_tune.NamedEntityRecognitionFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Tokenize the examples and prepare the features for training.
Parameters:
Name Type Description Default examplesDict[str, Union[List[str], List[int]]]
A dictionary of examples.
required
Returns:
Type Description Dict[str, Union[List[str], List[int]]]
Dict[str, Union[List[str], List[int]]]: The processed features.
"},{"location":"text/fine_tune/nli/","title":"Natural Language Inference","text":"
Bases: TextFineTuner
A bolt for fine-tuning Hugging Face models for text classification tasks.
This class extends the TextFineTuner and specializes in fine-tuning models for text classification. It provides additional functionalities for loading and preprocessing text classification datasets in various formats.
Load a commonsense reasoning dataset from a directory.
Parameters:
Name Type Description Default dataset_pathstr
The path to the dataset directory.
required **kwargsAny
Additional keyword arguments.
{}
Returns:
Name Type Description DatasetUnion[Dataset, DatasetDict, None]
The loaded dataset.
Raises:
Type Description Exception
If there was an error loading the dataset.
"},{"location":"text/fine_tune/nli/#geniusrise_text.nli.fine_tune.NLIFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/nli/#geniusrise_text.nli.fine_tune.NLIFineTuner.load_dataset--hugging-face-dataset","title":"Hugging Face Dataset","text":"
Dataset files saved by the Hugging Face datasets library.
Args:\n input (BatchInput): The batch input data.\n output (OutputConfig): The output data.\n state (State): The state manager.\n **kwargs: Additional keyword arguments.\n
"},{"location":"text/fine_tune/question_answering/#geniusrise_text.qa.fine_tune.QAFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/question_answering/#geniusrise_text.qa.fine_tune.QAFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
"},{"location":"text/fine_tune/summarization/#geniusrise_text.summarization.fine_tune.SummarizationFineTuner.load_dataset--supported-data-formats-and-structures","title":"Supported Data Formats and Structures:","text":""},{"location":"text/fine_tune/summarization/#geniusrise_text.summarization.fine_tune.SummarizationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
{\"text\": \"The text content\", \"summary\": \"The summary\"}\n
A bolt for fine-tuning Hugging Face models on translation tasks.
Args:\n input (BatchInput): The batch input data.\n output (OutputConfig): The output data.\n state (State): The state manager.\n **kwargs: Arbitrary keyword arguments for extended functionality.\n
"},{"location":"text/fine_tune/translation/#geniusrise_text.translation.fine_tune.TranslationFineTuner.load_dataset--supported-data-formats-and-structures-for-translation-tasks","title":"Supported Data Formats and Structures for Translation Tasks:","text":""},{"location":"text/fine_tune/translation/#geniusrise_text.translation.fine_tune.TranslationFineTuner.load_dataset--jsonl","title":"JSONL","text":"
Each line is a JSON object representing an example.
The VisionAPI class inherits from VisionBulk and is designed to facilitate the handling of vision-based tasks using a pre-trained machine learning model. It sets up a server to process image-related requests using a specified model.
ImageClassificationAPI extends the VisionAPI for image classification tasks. This API provides functionalities to classify images into various categories based on the trained model it uses. It supports both single-label and multi-label classification problems.
Methods
classify_image(self): Endpoint to classify an uploaded image and return the classification scores. sigmoid(self, _outputs): Applies the sigmoid function to the model's outputs. softmax(self, _outputs): Applies the softmax function to the model's outputs.
Initializes the ImageClassificationAPI with the necessary configurations for input, output, and state management, along with model-specific parameters.
Parameters:
Name Type Description Default inputBatchInput
Configuration for the input data.
required outputBatchOutput
Configuration for the output data.
required stateState
State management for the API.
required **kwargs
Additional keyword arguments for extended functionality, such as model configuration.
Endpoint for classifying an image. It accepts a base64-encoded image, decodes it, preprocesses it, and runs it through the classification model. It supports both single-label and multi-label classification by applying the appropriate post-processing function to the model outputs.
Returns:
Type Description Dict[str, Any]
Dict[str, Any]: A dictionary containing the predictions with the highest scores and all prediction scores.
Dict[str, Any]
Each prediction includes the label and its corresponding score.
Raises:
Type Description Exception
If an error occurs during image processing or classification.
Example CURL Request:
curl -X POST localhost:3000/api/v1/classify_image -H \"Content-Type: application/json\" -d '{\"image_base64\": \"<base64-encoded-image>\"}'\n
ImageOCRAPI provides Optical Character Recognition (OCR) capabilities for images, leveraging different OCR engines like EasyOCR, PaddleOCR, and Hugging Face models tailored for OCR tasks. This API can decode base64-encoded images, process them through the chosen OCR engine, and return the recognized text.
The API supports dynamic selection of OCR engines and configurations based on the provided model name and arguments, offering flexibility in processing various languages and image types.
Methods
ocr(self): Processes an uploaded image for OCR and returns the recognized text.
Endpoint for performing OCR on an uploaded image. It accepts a base64-encoded image, decodes it, preprocesses it through the specified OCR model, and returns the recognized text.
Returns:
Type Description
Dict[str, Any]: A dictionary containing the success status, recognized text ('result'), and the original
image name ('image_name') if provided.
Raises:
Type Description Exception
If an error occurs during image processing or OCR.
Processes the image using a Hugging Face model specified for OCR tasks. Supports advanced configurations and post-processing to handle various OCR-related challenges.
Parameters:
Name Type Description Default imageImage.Image
The image to process.
required use_easyocr_bboxbool
Whether to use EasyOCR to detect text bounding boxes before processing with Hugging Face models.
VisionSegmentationAPI extends VisionAPI to provide image segmentation functionalities, including panoptic, instance, and semantic segmentation. This API supports different segmentation tasks based on the model's capabilities and the specified subtask in the request.
Methods
segment_image(self): Processes an image for segmentation and returns the segmentation masks along with labels.
Initializes the VisionSegmentationAPI with configurations for input, output, and state management, along with any model-specific parameters for segmentation tasks.
Parameters:
Name Type Description Default inputBatchInput
Configuration for the input data.
required outputBatchOutput
Configuration for the output data.
required stateState
State management for the API.
required **kwargs
Additional keyword arguments for extended functionality.
Endpoint for segmenting an image according to the specified subtask (panoptic, instance, or semantic segmentation). It decodes the base64-encoded image, processes it through the model, and returns the segmentation masks along with labels and scores (if applicable) in base64 format.
The method supports dynamic task inputs for models requiring specific task descriptions and applies different post-processing techniques based on the subtask.
Returns:
Type Description List[Dict[str, Any]]
List[Dict[str, Any]]: A list of dictionaries where each dictionary contains a 'label', a 'score' (if applicable),
List[Dict[str, Any]]
and a 'mask' (base64-encoded image of the segmentation mask).
Raises:
Type Description Exception
If an error occurs during image processing or segmentation.
VisualQAAPI extends VisionAPI to provide an interface for visual question answering (VQA) tasks. This API supports answering questions about an image by utilizing deep learning models specifically trained for VQA. It processes requests containing an image and a question about the image, performs inference using the loaded model, and returns the predicted answer.
Methods
answer_question(self): Receives an image and a question, returns the answer based on visual content.
Initializes the VisualQAAPI with configurations for input, output, state management, and any model-specific parameters for visual question answering tasks.
Parameters:
Name Type Description Default inputBatchInput
Configuration for the input data.
required outputBatchOutput
Configuration for the output data.
required stateState
State management for the API.
required **kwargs
Additional keyword arguments for extended functionality.
Endpoint for receiving an image with a question and returning the answer based on the visual content of the image. It processes the request containing a base64-encoded image and a question string, and utilizes the loaded model to predict the answer to the question related to the image.
Returns:
Type Description
Dict[str, Any]: A dictionary containing the original question and the predicted answer.
Raises:
Type Description ValueError
If required fields 'image_base64' and 'question' are not provided in the request.
Exception
If an error occurs during image processing or inference.
Example CURL Request:
curl -X POST localhost:3000/api/v1/answer_question -H \"Content-Type: application/json\" -d '{\"image_base64\": \"<base64-encoded-image>\", \"question\": \"What is the color of the sky in the image?\"}'\n
or
(base64 -w 0 test_images_segment_finetune/image1.jpg | awk '{print \"{\"image_base64\": \"\"$0\"\", \"question\": \"how many cats are there?\"}\"}' > /tmp/image_payload.json)\ncurl -X POST http://localhost:3000/api/v1/answer_question -H \"Content-Type: application/json\" -u user:password -d @/tmp/image_payload.json | jq\n