Spaces:
Running
Running
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>LLaMA-Pro Dry Run</title> | |
<style> | |
body { | |
font-family: sans-serif; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
min-height: 100vh; | |
background-color: #f4f4f4; | |
margin: 0; | |
} | |
.container { | |
background: white; | |
padding: 20px; | |
border-radius: 8px; | |
box-shadow: 0 0 10px rgba(0,0,0,0.1); | |
width: 400px; | |
} | |
.input-group { | |
margin-bottom: 10px; | |
} | |
.input-group label { | |
display: block; | |
margin-bottom: 5px; | |
} | |
.input-group input { | |
width: 100%; | |
padding: 8px; | |
border: 1px solid #ddd; | |
border-radius: 4px; | |
box-sizing: border-box; | |
} | |
button { | |
background-color: #007bff; | |
color: white; | |
border: none; | |
padding: 10px 15px; | |
border-radius: 4px; | |
cursor: pointer; | |
margin-bottom: 15px; | |
} | |
button:hover { | |
background-color: #0056b3; | |
} | |
.output { | |
margin-bottom: 20px; | |
} | |
pre { | |
background-color: #f9f9f9; | |
padding: 10px; | |
border: 1px solid #eee; | |
white-space: pre-wrap; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Model Expansion with LLaMA-Pro</h1> | |
<div class="input-group"> | |
<label for="originalLayers">Original Layers:</label> | |
<input type="number" id="originalLayers" value="32"> | |
</div> | |
<div class="input-group"> | |
<label for="targetLayers">Target Layers:</label> | |
<input type="number" id="targetLayers" value="40"> | |
</div> | |
<button id="calculateButton">Calculate Duplicated Layers</button> | |
<div class="output"> | |
<h2>Output Array:</h2> | |
<pre id="outputArray"></pre> | |
</div> | |
<div class="logs"> | |
<h2>Logs:</h2> | |
<pre id="logs"></pre> | |
</div> | |
</div> | |
<script> | |
document.getElementById('calculateButton').addEventListener('click', function() { | |
const originalLayers = parseInt(document.getElementById('originalLayers').value); | |
const targetLayers = parseInt(document.getElementById('targetLayers').value); | |
const outputArrayElement = document.getElementById('outputArray'); | |
const logsElement = document.getElementById('logs'); | |
logsElement.textContent = ""; // Clear previous logs | |
function logMessage(message) { | |
logsElement.textContent += message + "\n"; | |
} | |
function validateInputs(originalLayers, targetLayers){ | |
if (isNaN(originalLayers) || isNaN(targetLayers)) { | |
logMessage("Error: Layer counts must be numeric values."); | |
return false; | |
} | |
if(originalLayers <= 0){ | |
logMessage("Error: Original layers must be positive."); | |
return false; | |
} | |
if (targetLayers <= 0) { | |
logMessage("Error: Target layers must be positive."); | |
return false; | |
} | |
if (targetLayers <= originalLayers) { | |
logMessage("Error: Target layers must be greater than original layers."); | |
return false; | |
} | |
if (!Number.isInteger(originalLayers) || !Number.isInteger(targetLayers)) { | |
logMessage("Error: Layer counts must be integers."); | |
return false; | |
} | |
return true | |
} | |
if (!validateInputs(originalLayers, targetLayers)){ | |
outputArrayElement.textContent = "[]"; | |
return | |
} | |
logMessage("Starting dry run calculation..."); | |
let duplicatedLayers = []; | |
let layerCount = 0; | |
const additionalLayers = targetLayers - originalLayers; | |
if (additionalLayers <= 0){ | |
logMessage("Error: Invalid layer configuration"); | |
outputArrayElement.textContent = "[]"; | |
return | |
} | |
const split = Math.floor(originalLayers / additionalLayers); | |
if (split === 0){ | |
logMessage("Error: Split factor calculation resulted in zero"); | |
outputArrayElement.textContent = "[]"; | |
return | |
} | |
logMessage("Split factor calculated: " + split); | |
for (let i = 0; i < originalLayers; i++){ | |
logMessage("Processing layer " + (i + 1) + "/" + originalLayers); | |
duplicatedLayers.push(i); | |
layerCount++; | |
if ((i + 1) % split === 0 && layerCount < targetLayers) { | |
logMessage("Duplicating layer " + (i+1)); | |
duplicatedLayers.push(i); | |
layerCount++; | |
} | |
} | |
if(layerCount != targetLayers){ | |
logMessage("Error: Layer count mismatch. Expected " + targetLayers + ", got " + layerCount); | |
outputArrayElement.textContent = "[]"; | |
return | |
} | |
logMessage("Dry run completed successfully"); | |
outputArrayElement.textContent = JSON.stringify(duplicatedLayers, null, 2); | |
}); | |
</script> | |
</body> | |
</html> |