Downloads · 30 days
13
24% of all-time downloads
bhismaperkasa/gemma-3-1B-it-form-generator-q4_4096-tflite
gemma-3-1B-it-form-generator-q4_4096-tflite is a machine learning model from bhismaperkasa. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Production-ready TFLite models untuk Android deployment dengan MediaPipe. 3 quantization options: FP32, FP16, INT8.
Downloads · 30 days
13
24% of all-time downloads
All-time downloads
54
Public
Repo size
1.1 GB
Likes
0
Public
Click a slice to open those files.
.task571 MB · 50%
From the Hugging Face model README
Production-ready TFLite models untuk Android deployment dengan MediaPipe. 3 quantization options: FP32, FP16, INT8.
model_int8.tflitemodel_float16.tflitemodel_float32.tflite# Download INT8 model (recommended)
wget https://huggingface.co/bhismaperkasa/gemma-3-1B-it-form-generator-q4_4096-tflite/resolve/main/model_int8.tflite
app/
src/
main/
assets/
model_int8.tflite ← Copy here
// app/build.gradle
dependencies {
implementation 'org.tensorflow:tensorflow-lite:2.14.0'
implementation 'org.tensorflow:tensorflow-lite-gpu:2.14.0'
implementation 'org.tensorflow:tensorflow-lite-support:0.4.4'
}
import org.tensorflow.lite.Interpreter
import java.io.FileInputStream
import java.nio.MappedByteBuffer
import java.nio.channels.FileChannel
class FormGeneratorModel(context: Context) {
private val interpreter: Interpreter
init {
// Load model
val model = loadModelFile(context, "model_int8.tflite")
// Configure interpreter
val options = Interpreter.Options()
options.setNumThreads(4) // Use 4 threads
interpreter = Interpreter(model, options)
}
private fun loadModelFile(context: Context, filename: String): MappedByteBuffer {
val assetFileDescriptor = context.assets.openFd(filename)
val inputStream = FileInputStream(assetFileDescriptor.fileDescriptor)
val fileChannel = inputStream.channel
val startOffset = assetFileDescriptor.startOffset
val declaredLength = assetFileDescriptor.declaredLength
return fileChannel.map(
FileChannel.MapMode.READ_ONLY,
startOffset,
declaredLength
)
}
fun generateForm(prompt: String): String {
// Tokenize input
val inputTokens = tokenizer.encode(prompt)
// Prepare input tensors
val inputArray = Array(1) { inputTokens }
// Prepare output tensors
val outputArray = Array(1) { IntArray(512) }
// Run inference
interpreter.run(inputArray, outputArray)
// Decode output
val result = tokenizer.decode(outputArray[0])
return result
}
fun close() {
interpreter.close()
}
}
class MainActivity : AppCompatActivity() {
private lateinit var model: FormGeneratorModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Load model
model = FormGeneratorModel(this)
// Generate form
val formJson = model.generateForm("buatkan form login")
// Parse & display
displayForm(formJson)
}
override fun onDestroy() {
super.onDestroy()
model.close()
}
}
| Model | Init Time | Inference Time | Memory | Quality Score |
|---|---|---|---|---|
| INT8 | 2-3s | 1-2s | ~200 MB | 4.2/5.0 |
| FP16 | 3-4s | 2-3s | ~250 MB | 4.5/5.0 |
| FP32 | 4-5s | 3-5s | ~400 MB | 4.7/5.0 |
Example devices: Samsung S24, Pixel 9, iPhone 15 Pro
| Model | Init Time | Inference Time | Memory | Quality Score |
|---|---|---|---|---|
| INT8 | 3-5s | 2-4s | ~200 MB | 4.2/5.0 |
| FP16 | 5-7s | 4-6s | ~250 MB | 4.5/5.0 |
| FP32 | 7-10s | 6-10s | ~400 MB | 4.7/5.0 |
Example devices: Redmi Note 12, Galaxy A54
| Model | Init Time | Inference Time | Memory | Quality Score |
|---|---|---|---|---|
| INT8 | 5-8s | 4-8s | ~250 MB | 4.2/5.0 |
| FP16 | 8-12s | 8-15s | ~300 MB | 4.5/5.0 |
| FP32 | Not recommended | - | - | - |
Example devices: Entry-level Redmi, Samsung A-series
Input:
buatkan form login dengan email dan password
Output:
{
"id": "form_login_001",
"title": "Form Login",
"category": "authentication",
"formDefinition": {
"sections": [
{
"sectionId": "section_1",
"title": "Login",
"fields": [
{
"fieldId": "email",
"label": "Email",
"fieldType": "EMAIL",
"required": true,
"placeholder": "Masukkan email"
},
{
"fieldId": "password",
"label": "Password",
"fieldType": "PASSWORD",
"required": true,
"placeholder": "Masukkan password"
}
]
}
]
}
}
val options = Interpreter.Options()
val gpuDelegate = GpuDelegate()
options.addDelegate(gpuDelegate)
val options = Interpreter.Options()
val nnApiDelegate = NnApiDelegate()
options.addDelegate(nnApiDelegate)
// Use CPU core count
val numThreads = Runtime.getRuntime().availableProcessors()
options.setNumThreads(numThreads)
// Load once, reuse multiple times
companion object {
private var cachedInterpreter: Interpreter? = null
}
Apache 2.0 (following Gemma license)
For issues or questions:
Ready for production Android apps! 🚀📱