A newer version of this model is available:
deepseek-ai/DeepSeek-V3-Base
Model Card for {{ model_id | default("Model ID", true) }}
A multimodel assistant{{ model_summary | default("", true) }}
Model Details
Model Description
{{ model_description | default("", true) }}
- Developed by: {{ developers | default("[More Information Needed]", true)}}
- Funded by [optional]: {{ funded_by | default("[More Information Needed]", true)}}
- Shared by [optional]: {{ shared_by | default("[More Information Needed]", true)}}
- Model type: {{ model_type | default("[More Information Needed]", true)}}
- Language(s) (NLP): {{ language | default("[More Information Needed]", true)}}
- License: {{ license | default("[More Information Needed]", true)}}
- Finetuned from model [optional]: {{ base_model | default("[More Information Needed]", true)}}
Model Sources [optional]
- Repository: {{ repo | default("[More Information Needed]", true)}}
- Paper [optional]: {{ paper | default("[More Information Needed]", true)}}
- Demo [optional]: {{ demo | default("[More Information Needed]", true)}}
Uses
Direct Use
{{ direct_use | default("[More Information Needed]", true)}}
Downstream Use [optional]
{{ downstream_use | default("[More Information Needed]", true)}}
Out-of-Scope Use
{{ out_of_scope_use | default("[More Information Needed]", true)}}
Bias, Risks, and Limitations
{{ bias_risks_limitations | default("[More Information Needed]", true)}}
Recommendations
{{ bias_recommendations | default("Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.", true)}}
How to Get Started with the Model
Use the code below to get started with the model.
import subprocess
import sys
import os
# Function to install a package
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
# List of required packages
required_packages = ["transformers", "torch", "vaderSentiment", "nltk", "fastai", "fastcore", "toml"]
# Install required packages
for package in required_packages:
install(package)
# Now we can safely import the installed packages
import gc
from transformers import pipeline
import gradio as gr
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import nltk
from nltk.tokenize import word_tokenize
nltk.download('punkt', quiet=True)
# Define the UltimateReasoningSystem class
class UltimateReasoningSystem:
def __init__(self):
self.knowledgeGraph = KnowledgeGraph()
self.perspectiveManager = PerspectiveManager()
self.emotionManager = EmotionManager()
self.dataSources = [WikipediaDataSource(), RedditDataSource()]
def generateResponse(self, question):
questionAnalysis = self.analyzeQuestion(question)
perspective = self.perspectiveManager.determinePerspective(questionAnalysis)
emotion = self.emotionManager.determineEmotion(questionAnalysis)
response = self.generateResponseUsingPerspectiveAndEmotion(perspective, emotion, questionAnalysis)
return response
def analyzeQuestion(self, question):
tokens = self.tokenizeQuestion(question)
posTags = self.posTagTokens(tokens)
namedEntities = self.namedEntityRecognizeTokens(tokens)
dependencyParse = self.dependencyParseTokens(tokens)
return {
'tokens': tokens,
'posTags': posTags,
'namedEntities': namedEntities,
'dependencyParse': dependencyParse,
}
def tokenizeQuestion(self, question):
tokenizer = Tokenizer()
tokens = tokenizer.tokenize(question)
return tokens
def posTagTokens(self, tokens):
posTagger = PosTagger()
posTags = posTagger.tag(tokens)
return posTags
def namedEntityRecognizeTokens(self, tokens):
namedEntityRecognizer = NamedEntityRecognizer()
namedEntities = namedEntityRecognizer.recognize(tokens)
return namedEntities
def dependencyParseTokens(self, tokens):
dependencyParser = DependencyParser()
dependencyParse = dependencyParser.parse(tokens)
return dependencyParse
def generateResponseUsingPerspectiveAndEmotion(self, perspective, emotion, questionAnalysis):
response = self.generateResponseUsingPerspectiveAndEmotionHelper(perspective, emotion, questionAnalysis)
return response
def generateResponseUsingPerspectiveAndEmotionHelper(self, perspective, emotion, questionAnalysis):
knowledgeGraph = self.knowledgeGraph
response = knowledgeGraph.generateResponse(perspective, emotion, questionAnalysis)
return response
class KnowledgeGraph:
def __init__(self):
self.graph = Graph()
def generateResponse(self, perspective, emotion, questionAnalysis):
response = self.graph.generateResponse(perspective, emotion, questionAnalysis)
return response
class Graph:
def __init__(self):
self.nodes = []
self.edges = []
def generateResponse(self, perspective, emotion, questionAnalysis):
response = self.generateResponseHelper(perspective, emotion, questionAnalysis)
return response
def generateResponseHelper(self, perspective, emotion, questionAnalysis):
response = self.generateResponseHelperHelper(perspective, emotion, questionAnalysis)
return response
def generateResponseHelperHelper(self, perspective, emotion, questionAnalysis):
response = 'This is a response.'
return response
class PerspectiveManager:
def __init__(self):
self.perspectives = [NewtonianPerspective(), DaVincianPerspective()]
def determinePerspective(self, questionAnalysis):
perspective = self.perspectives[0]
return perspective
class EmotionManager:
def __init__(self):
self.emotions = [HappyEmotion(), SadEmotion()]
def determineEmotion(self, questionAnalysis):
emotion = self.emotions[0]
return emotion
class NewtonianPerspective:
def getPerspectiveDescription(self):
perspectiveDescription = 'This perspective is Newtonian.'
return perspectiveDescription
class DaVincianPerspective:
def getPerspectiveDescription(self):
perspectiveDescription = 'This perspective is DaVincian.'
return perspectiveDescription
class HappyEmotion:
def getEmotionDescription(self):
emotionDescription = 'This emotion is happy.'
return emotionDescription
class SadEmotion:
def getEmotionDescription(self):
emotionDescription = 'This emotion is sad.'
return emotionDescription
class WikipediaDataSource:
def getDataDescription(self):
dataDescription = 'This data is from Wikipedia.'
return dataDescription
class RedditDataSource:
def getDataDescription(self):
dataDescription = 'This data is from Reddit.'
return dataDescription
class Tokenizer:
def tokenize(self, text):
return text.split()
class PosTagger:
def tag(self, tokens):
return [('NN', token) for token in tokens]
class NamedEntityRecognizer:
def recognize(self, tokens):
return ['ENTITY' for _ in tokens]
class DependencyParser:
def parse(self, tokens):
return [('ROOT', token) for token in tokens]
# Initialize the text-generation pipeline with a smaller model to reduce memory usage
pipe = pipeline("text-generation", model="distilgpt2", device=-1)
def generate_text(prompt):
# Use the pipeline to generate text with adjusted parameters
results = pipe(prompt, max_length=50, num_return_sequences=1, temperature=0.9, top_p=0.9)
# Extract the generated text
generated_text = results[0]['generated_text']
# Check for repetitive output and regenerate if necessary
if "Ethical Considerations" in generated_text:
results = pipe(prompt, max_length=50, num_return_sequences=1, temperature=1.0, top_p=0.8)
generated_text = results[0]['generated_text']
return generated_text
async def respond(
message,
history: list[dict],
system_message,
max_tokens,
temperature,
top_p,
):
ultimate_reasoning_system = UltimateReasoningSystem()
response = ultimate_reasoning_system.generateResponse(message)
# Clear unused variables to free up memory
gc.collect()
yield response
demo = gr.ChatInterface(
respond,
additional_inputs=[
gr.Textbox(value="You are a friendly, professional, and knowledgeable chatbot who enjoys casual conversations and offers empathetic, supportive responses.", label="System message"),
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"), # Fixed comma
gr.Slider(
minimum=0.1,
maximum=1.0,
value=0.95,
step=0.05,
label="Top-p (nucleus sampling)",
),
],
type="messages" # Update this line to use the 'messages' format
)
if __name__ == "__main__":
demo.launch()
Inference API (serverless) does not yet support fastai models for this pipeline type.
Model tree for Raiff1982/coder
Base model
Qwen/Qwen2.5-32B
Finetuned
Qwen/Qwen2.5-32B-Instruct
Finetuned
NovaSky-AI/Sky-T1-32B-Preview