Skip to content

Cohere command model

Ahmad Albarqawi edited this page Mar 5, 2023 · 1 revision

Cohere.ai provides a fine-tuned command model to generate advanced text like a blog post.

Helper function for cohere blog post generation:

public static void writeBlogArticle(String key, String instruction, String model) {
		
	RemoteLanguageModel lang = new RemoteLanguageModel(key, SupportedLangModels.cohere);
	LanguageModelInput input = new LanguageModelInput.Builder(instruction).
    			setMaxTokens(600).setModel("command-xlarge-20221108").setTemperature(0.8f).build();
		
	try {
           System.out.println(lang.generateText(input));
	} catch (IOException e) {
           e.printStackTrace();
	}
}

Model parameters and method execution:

String key = "<add-key-from-cohere.ai>";
String instruction = "Write a blog outline for a blog titled \\\"The Art of Effective Communication: Tips and Tricks for Better Interactions\\\"";
String model = "command-xlarge-20221108";
writeBlogArticle(key, instruction, model);
Clone this wiki locally