Skip to main content

StreamFinetuner

StreamFinetuner

The StreamFinetuner in Nstream AI is a real-time model fine-tuning component that continuously adapts AI models using streaming data, ensuring they evolve with dynamic patterns and context. By leveraging a KnowledgeBase for contextual retrieval, it enhances model accuracy and relevance, making it ideal for high-throughput AI-driven workflows like retrieval-augmented generation (RAG), fraud detection, and market intelligence. Designed for seamless deployment in a Kubernetes-native environment, StreamFinetuner enables AI models to learn from live data, improving real-time inference and decision-making for streaming applications.

Sample YAML Configuration

apiVersion: llm.nstream.ai/v1
kind: StreamFinetuner
metadata:
name: "STREAMFINETUNER_NAME"
namespace: "NAMESPACE"
spec:
finetunerInfo:
baseModel: "BASE_MODEL"
dataSource:
sourceStreamConnector: "SOURCE_FINETUNE_CONNECTOR"
sourceStreamFinetuner: "OPTIONAL_STREAM_FINETUNER"
knowledgeBase: "KNOWLEDGEBASE_NAME"
megaModel: "MEGAMODEL_NAME"
finetunerTemplate:
dataProcessorTemplate:
checkpointingInterval: "CHECKPOINT_INTERVAL"
flinkMemorySize: "FLINK_MEMORY"
managedMemorySize: "MANAGED_MEMORY"
parallelism: PARALLELISM_LEVEL
processMemorySize: "PROCESS_MEMORY"
finetunerResources:
limits:
cpu: "CPU_LIMIT"
gpu: "GPU_LIMIT"
memory: "MEMORY_LIMIT"
requests:
cpu: "CPU_REQUEST"
gpu: "GPU_REQUEST"
memory: "MEMORY_REQUEST"
preProcessing:
knowledgeSearchLimit: KNOWLEDGE_SEARCH_LIMIT
preProcessingSQL: "PREPROCESSING_SQL_QUERY"
sampleRatio: "SAMPLE_RATIO"
ioSequenceLength:
inputMax: "INPUT_MAX_LENGTH"
outputMax: "OUTPUT_MAX_LENGTH"
promptTemplate:
- systemContext: "SYSTEM_CONTEXT"
userQuestion: "USER_QUESTION"
trainer:
batchSize: "BATCH_SIZE"
epochs: "EPOCHS"
gradientAccumulationSteps: "GRADIENT_ACCUMULATION_STEPS"
learningRate: "LEARNING_RATE"
useMixedPrecision: "MIXED_PRECISION"

YAML Configuration Parameters

KeyDescriptionExample
apiVersionDefines the API version for the configurationllm.nstream.ai/v1
kindIdentifies the type of resource being configuredStreamFinetuner
nameUnique name for the StreamFinetuner instancenode-1-finetuner
namespaceKubernetes namespace where the instance is deployeddefault
baseModelBase language model to be fine-tunedllama3-8b-instruct
dataSource.sourceStreamConnectorConnector for the source stream dataevent-source-connector
knowledgeBaseReference to the associated KnowledgeBasenode-1-kb
megaModelReference to a mega model used to generate grounded responsesazure-openai-4o
checkpointingIntervalInterval for data checkpointing5m
flinkMemorySizeMemory allocated to Flink processes8192m
cpuCPU resource limit for the finetuning process8000m
preProcessingSQLSQL query for preprocessing the input dataSELECT * FROM source_stream WHERE event_time >= now() - interval '1 day';
systemContextContext provided to the model for generating responses"You are a Financial Analyst with specialized expertise in interpreting Open-High-Low-Close (OHLC) data."
WlearningRateLearning rate for model training0.00005