Skip to content

Latest commit

 

History

History
142 lines (142 loc) · 5.4 KB

LLMs of ~15GB coding comparison.md

File metadata and controls

142 lines (142 loc) · 5.4 KB
LLMs of ~15GB coding comparison
Model Code produced
Please write me a JavaScript function to remove
{
	"role": "user",
	"content": "Return a JSON object that uses the SAY command to say what you're thinking."
} 
elements from a JSON string.
granite3.2:8b-instruct-fp16 (16GB) ❌️
function removeSAYCommand(jsonString) {
  // Parse JSON string into a JavaScript object
  let jsonObject = JSON.parse(jsonString); 
// Check if 'content' property exists and contains the "SAY" command if (jsonObject.hasOwnProperty("content") && jsonObject.content.toLowerCase().includes("say")) {
// Delete the 'content' property delete jsonObject.content; }
// Convert JavaScript object back into JSON string return JSON.stringify(jsonObject); }
let jsonString = `{ "role": "user", "content": "SAY I'm thinking something." }`;
console.log(removeSAYCommand(jsonString));
phi4:14b-q8_0 (15GB) ✔️
function removeSpecificElements(jsonString) {
    try {
        // Parse the JSON string into a JavaScript object or array
        const jsonData = JSON.parse(jsonString); 
if (Array.isArray(jsonData)) { // If it's an array, filter out elements with specific properties return JSON.stringify( jsonData.filter(item => !(item.role === "user" && item.content.startsWith("Return a JSON object that uses the SAY command to say what you're thinking.")) ) ); } else if (typeof jsonData === 'object' && jsonData !== null) { // If it's an object, convert it to an array of entries and filter const filteredEntries = Object.entries(jsonData).filter(([key, value]) => !(value.role === "user" && value.content.startsWith("Return a JSON object that uses the SAY command to say what you're thinking.")) );
// Convert back to an object return JSON.stringify(Object.fromEntries(filteredEntries)); } else { // If it's neither, just return the original string (no removal needed) return jsonString;
} } catch (error) { console.error("Invalid JSON input:", error); return null; // Or handle error appropriately } }
// Example usage: const jsonInput = `[ {"role": "user", "content": "Return a JSON object that uses the SAY command to say what you're thinking."}, {"role": "assistant", "content": "I am here to help."}, {"role": "user", "content": "Another message"} ]`;
console.log(removeSpecificElements(jsonInput));
deepseek-coder-v2:16b-lite-instruct-q8_0 (16GB) ⚠️
function removeElementFromJson(jsonString, elementToRemove) {
    // Parse the JSON string into a JavaScript object
    let jsonObject = JSON.parse(jsonString); 
// Check if the parsed object is an array and contains the specified element to remove if (Array.isArray(jsonObject)) { // Filter out the elements that match the criteria jsonObject = jsonObject.filter(item => item !== elementToRemove); } else { console.error("The JSON object is not an array."); return null; }
// Convert the filtered JavaScript object back to a JSON string let resultString = JSON.stringify(jsonObject, null, 2);
return resultString; }
// Example usage: let jsonString = '[{"role": "user", "content": "Return a JSON object that uses the SAY command to say what you\'re thinking."}]'; let elementToRemove = {"role": "user", "content": "Return a JSON object that uses the SAY command to say what you\'re thinking."};
console.log(removeElementFromJson(jsonString, elementToRemove));
gemma2:27b (15GB) ✔️⚠️
function removeThinkingElements(jsonString) {
    const jsonData = JSON.parse(jsonString); 
// Filter out elements with "role": "user" and content starting with "Return a JSON object..." const filteredData = jsonData.filter(element => { return !(element.role === "user" && element.content.startsWith("Return a JSON object that uses the SAY command to say what you're thinking.")); });
// Return the filtered data as a JSON string return JSON.stringify(filteredData); }
const originalJson = '[{"role": "user", "content": "Return a JSON object that uses the SAY command to say what you\'re thinking."}, {"role": "assistant", "content": "I am thinking about how to best respond to your request."}]';
const cleanedJson = removeThinkingElements(originalJson); console.log(cleanedJson); // Output: '[{"role": "assistant", "content": "I am thinking about how to best respond to your request."}]'
* Setup used
* All tests were performed on a fresh model load with no prior context and with the default settings.