This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:cactus/cactus.dart'; | |
final vlm = await CactusVLM.init( | |
modelUrl: 'huggingface/gguf/vision-model/link', // URL to VLM GGUF | |
mmprojUrl: 'huggingface/gguf/mmproj/link', // URL to mmproj GGUF | |
); | |
final messages = [ | |
ChatMessage(role: 'user', content: 'Describe what you see in this image.') | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:cactus/cactus.dart'; | |
// pass in conversation history | |
final messages = [ | |
ChatMessage(role: 'system', content: 'You are a helpful assistant.'), | |
ChatMessage(role: 'user', content: 'What is the capital of France?') | |
]; | |
// run inference (lm is your previously initialized model) | |
final response = await lm.completion( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:cactus/cactus.dart'; | |
final lm = await CactusLM.init( | |
modelUrl: 'https://huggingface.co/Cactus-Compute/Qwen3-600m-Instruct-GGUF/resolve/main/Qwen3-0.6B-Q8_0.gguf', | |
contextSize: 2048, // The context size for the model. | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CactusVLM } from 'cactus-react-native'; | |
// Initialize the Vision Language Model. | |
const { vlm, error } = await CactusVLM.init({ | |
model: '/path/to/vision-model.gguf', | |
mmproj: '/path/to/mmproj.gguf', // The projector file for the vision model. | |
}); | |
if (error) { | |
console.error('Failed to initialize VLM:', error); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CactusLM } from 'cactus-react-native'; | |
// Initialize the model. The localPath is the path to your previously downloaded model. | |
const { lm, error } = await CactusLM.init({ | |
model: localPath, | |
n_ctx: 2048, // context window for your model | |
}); | |
if (error) { | |
console.error('Failed to initialize model:', error); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CactusLM } from 'cactus-react-native'; | |
// pass in conversation history | |
const messages = [ | |
{ role: 'system', content: 'You are a helpful assistant.' }, | |
{ role: 'user', content: 'What is the capital of France?' } | |
]; | |
// define inference parameters | |
const params = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RNFS from 'react-native-fs'; | |
const modelUrl = 'https://huggingface.co/Cactus-Compute/Qwen3-600m-Instruct-GGUF/resolve/main/Qwen3-0.6B-Q8_0.gguf'; | |
const localPath = `${RNFS.DocumentDirectoryPath}/${modelUrl.split('/').pop()}`; | |
// Download the model and log progress | |
await RNFS.downloadFile({ | |
fromUrl: modelUrl, | |
toFile: localPath, | |
progress: res => console.log(`${(res.bytesWritten / res.contentLength * 100).toFixed(2)}%`), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install cactus-react-native && npx pod-install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
x = np.arange(50)[:, np.newaxis] | |
y = np.array([i + np.random.rand() for i in range(50)])[:, np.newaxis] | |
ols_test = Model(x, y) | |
ols_test.fit(intercept=True) | |
ols_test.predict() | |
ols_test.plot_predictions() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_predictions(self): | |
plt.scatter(self.x, self.y, c='orange', label = 'Observed values') | |
plt.plot(self.x, self.y_hat, label = 'Fitted values') | |
plt.legend() | |
title_label = 'Fitted OLS Regression: intercept={}, slope={}'\ | |
.format(np.round(self.betas[0][0],2), np.round(self.betas[1][0],2)) | |
plt.title(label=title_label) | |
plt.show() |
NewerOlder