Giter Club home page Giter Club logo

mamba-minimal-dfdx-example's Introduction

mamba-minimal-dfdx-example

Click here to run the model in your browser.

Information

Adapted from huggingface/candle/mamba-minimal.

Building

Native
RUSTFLAGS="-C target-cpu=native"
cargo run --release --no-default-features --features "native"
WASM
# no-ui (web console only)
wasm-pack build --release --target web --no-default-features

# yew web ui
wasm-pack build --release --target web --no-default-features --features "wasm_yew_ui"

# serve
http -a 127.0.0.1

mamba-minimal-dfdx-example's People

Contributors

swfsql avatar

Stargazers

chris m avatar

Watchers

 avatar  avatar

mamba-minimal-dfdx-example's Issues

Is the minimal model finetuned to Q/A?

I'm currently porting the minimal example, and after the input of "Mamba is the".., the model has completed the sentence with something reasonable, and the model "ended" it's output with a signal that indicates the end of it's output.

Here is the output:

Mamba is the most popular and best-selling game in the world. It has been downloaded more than 1,000 times by over 1 million people worldwide since its release on November 7th 2016.

The Mamba series of games are based around a simple game that players can play to earn points for their efforts or to win prizes such as gold coins and diamonds. The game is played in the same way as any other video game, with each player having one turn at which they can earn points by completing certain tasks on top-down levels (such as jumping, climbing walls etc.).
The Mamba series of games are also available for download from the official website of the publisher and have been downloaded over 1.5 million times since its release in November 2016!

But when ignoring it's signaling and continuing predictions, carrying the same last state - I think indefinitely - the model 100% continued with Q/A predictions (with a specific QA structure, and most about programming), so it begs the question, is it finetuned to QA?

The continuation of the generated content

<|endoftext|>
Q:

How to get a list of all files that contain an extension?

I'm trying to get a list (or array) out with the following code, but I can't seem to get it right...
$file = "C:\Users\user\Desktop\test.txt"; // this is what I want 
$list = file_get_contents($file); 
    foreach ($list as $line){

        echo $line;  // prints out the line that contains an extension, but not a file name...
}   ​
I'm using PHP 5 and Apache 2.2 on Ubuntu 12.04 LTS 
Thanks in advance!
EDIT: I've tried the following code to get all files with an extension of .txt (which is what I want), however it doesn't work, any ideas?
$file = "C:\Users\user\Desktop\\test.txt"; // this works but not a file name... 
// $list = array();
$file = "C:/Users/user/Desktop/test.txt";  

    $file_name=$_GET['file']; 
        $line = explode(",",$file); 

            foreach ($line as $_) { // this is what I want... 
echo $line;  // prints out the line that contains an extension, but not a file name. 
                                                                }   ​

    }   ​
I've tried the following code:
$file = "C:/Users/user\Desktop\\test1.txt"; // this works... 
echo $line;  // prints out all files with extensions that contain an extension, but not a file name.. 
                                              // I'm trying to get it right now and I can't figure how!

A:

    $file = "C:/Users/user\Desktop\\test1.txt"; // this works... 
        echo $line;  
?>

$file_name=$_GET['file']; 
            // This is what you want to get with the extension
            if(strpos($file, '.') !== false){

                foreach ($file as $_): 

                    echo " ". strtr($_,"\t"); // this works... 
                            // I'm guessing this isn't what your looking for. 
                            // If you want to get all files with an extension that contains a .txt, use the following code:
                            if(strpos($file,'.') !== false){

                                echo " ". strtr($_,"\t"); // This works... 
                    }   ​
?>

EDIT 2: I think you're looking for something like this.  I'm not sure what you want to do with the extension, but it should work if your file is .txt and you want all files that contain an extension of .txt (or any other extension).  If so then you can use the following code in PHP:
$file = "C:/Users/user/.htaccess"; // this works... 
            if(strpos($file, '.') !== false){

                echo $line;// prints out all files that contain an .txt extension.
                            }   ​
?>

EDIT 3: I think you want to use the following code if your file is a directory and not just one of those extensions (like my example above): 
            if(strpos($file, '.') !== false){

                echo $line;// prints out all files that contain an extension.
<?php }   ​

<|endoftext|>
Q:

How to get the value from a textbox in asp.net?

I have this code which is working fine but I want it so when user clicks on "Add" button, it should add the value of the textbox and then it should show the value as well..
<asp:TextBox ID="txt_Name" runat = Server1 
    Text='<%# Bind("name") %>' />
</asp:DropDownList>
 <asp:Button ID="btnAdd" Text="add" OnClick= "return Add()" />

<asp:Label ID="lblNew" runat = Server1 
    Text='<%# Eval("name").ToString()%>'></asp:Label><br />
</asp:DropDownList>
 <asp:Button ID="btnAdd" Text="add" OnClick= "return Add()" />
<asp:TextBox ID="" runat = Server1 
    Text='<%# Bind("name") %>'></asp:TextBox>

 <asp:Label ID="lblNew" Runat = Server2 
    Text='<%# Eval("name").ToString()%>'></asp:Label><br />
</asp:DropDownList >
<asp:Button ID="" runat=Server1 
    Text="Add" OnClick= "return Add()" />

 <asp:TextBox ID="_txt_Name" runat = Server2 
    Text='<%# Eval("name") %>'></asp:TextBox>  </asp:DropDownList>
<asp:Button ID="" Runat = Server3 
    Text="Add" OnClick= "return Add()" />

 <asp:Label ID="_txt_Name" runat = Server4 
    Text='<%# Eval("name") %>'></asp:Label><br /><br />
</asp:DropDownList>  <br/>

A:

You can use the following code to get value from textbox and add it in asp.net control 
string txt_Name = "test"; //your text box name here 

string[] values = { "name", "value" };

    TextBox txt_Name1;  // your textBox Name here 

    string[] values1= { "name", "value1"};   <-- you can use this to get value from textbox and add it in asp.net control 

txt_Name = txt_Name1 + values1[0]; //your value is added into the textbox


<|endoftext|>
Q:

How to make a button click event on an element in javascript?

I have created a simple form with a submit button, and I want it so that when you click this button (which is inside of a div), then if there are any other elements within your form which contain the same text as my form's input field ("myForm"), they will be clicked.
Here what i've tried: 
<form id="submit" action="/index.php?action=Submit&id=1">
    <input type='text' name='myForm' value='test'>
</form> 

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11-jstools2+3/js/jquery_ujs.js"></script><script>
$(document).ready(function(){

    $('#submit').click(); //this is the code I'm trying to use in my script, but it doesn't work!
}); 
 </script>`
<div id="myForm">
    <input type='text' name='myForm'>
</form> 
<script>  
$(document).ready(function(){

        $('#submit').click(); //this is the code I'm trying to use in my script, but it doesn't work! 
     }); 

 </script>`   //This is where i want this button click event fired.

A:

You can use jQuery's .on() method for that purpose and then you just need a function like so : 
$('#submit').click(function(){

    var myForm = $('#submit'); //this is the code I'm trying to use in your script, but it doesn't work! 
     //This is where we want this button click event fired. 

  });   <---here you can use the .on() method for that

A: 
$('#submit').click(function(){

    var myForm = $('#submit'); //this works fine, but it doesn't work with .on().
     //This is where we want this button click event fired. 

  });   <---here you can use the function to call your function and then do whatever else that's needed in order for a button on an element (like a text input)


<|endoftext|>
Q:

How to get the value of a variable from another class?

I have two classes, one is called "A" which has a method named GetValue() ,and I want it so when user clicks on the button, that value should be displayed in the second A.
class A{

    public string Value; 
   public int Id; 


    public void SetValue(string id) {
        Id = (int)(id); //this is the variable to store this ID into
    } 

 }  //A class

I want it so that when user clicks on "GetValue" button, value should be displayed in A.

How can I do?

Thanks in advance! 

EDIT: 
Here's my code for getting the value from A :
public string GetValue() {

    A a = new A(); //this is the class that gets called when user clicks on "GetValue" button 

   return (a.Value);  //returns this variable in B class 
 }​

A:

You can use the following code to get value from A and store it into another class, then you could call it like this : 
A a = new A(); //this is your class that gets called when user clicks on "GetValue" button 


<|endoftext|>
Q:

How to make an array of objects in javascript?

I have the following code. I want my object to be an array, but not sure how do i do this with javascript or jquery... ive tried using a for loop and it doesnt seem like its working..
var obj = {
    name: 'John',
};

    for (var i=0;i<obj[0].length ;++j){ 
        console.log(obj); //this is not working, how do I make this work?
}​
//This is the code that isnt working...

A:

You can use a for loop to iterate over each object in your array and then assign it as an argument of .push() method on obj.

var obj = {
    name : 'John',

  };

for (var i=0;i<obj[0].length ;++j){

   console.log(obj); //this is not working, how do I make it work? 
      //This works!
     }​ 
// This will be the code that'snt working...


<|endoftext|>
Q:

How to get a list of all files in a directory?

I have an application which has many folders. Each folder is named with a different name, for example "C:\Users\user1\AppData\Local\Temp". I want each file from the C:\Users\user1\AppData\Local\Temp to be listed as a folder in my directory tree (I have no idea how to do this).
How can i get all files that are found within "C:\\Users\\user1\\AppData\\Local\\Temp" and then list them?
Thanks! 

A:

    string[] fileNames = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.txt"); //get the current directory of the application folder (in this case C:\Users\user1)
    foreach ((string fileName) in fileNames){
        string filePath = Path.Combine(fileName, fileName);


<|endoftext|>

Work in firefox with "safer" settings

On firefox with security at "safer" (options are "standard", "safer" and "safest") the metadata checking step crashes with a CORS error:

Cross-Origin Request Blocked:
The Same Origin Policy disallows reading the remote resource at 
https://cdn-lfs-us-1.huggingface.co/repos/[redacted]?response-content-disposition=attachment%3B+filename*%3DUTF-8%27%27model.safetensors%3B+filename%3D%22model.safetensors%22%3B&Expires=1709457896&Policy=[redacted]&Signature=[redacted]&Key-Pair-Id=[redacted].
(Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 403.

I don't know how to fix this. On chrome with standard settings it does work.

Support offline mode

This applies for huggingface - that means caching the metadata - and (eventual) custom urls information, and also for model uploading.
But before this, check if a complete offline mode is at all possible, starting from an offline whole page reload.

In case offline mode is possible, make the api connection (fetch client and indexedDB connections) to be optional and allow for the user to interactively connect and/or disconnect from it.

Check why the app keeps running even after the main thread has finished

The yew renderer starts the rendering but then returns, and the main thread presumably finished. Normally this means other threads get killed and the program gets deallocated, but somehow the yew app keeps running even after it returns.

Check why this is, and possibly try to prevent yew from returning.

Use webworkers (wasm)

Webworkers could function as background threads for the wasm app.

Furthermore, webworkers may be the solution to the fetch shortcomings for getting the header information of urls that get redirected. This needs to be checked and tested on hf-hub.

Webworkers could be applied on slow and sync operations, such as:

  • Model building.
  • Inference.

Consider removing the `lm_head` layer

This layer uses the same weight information from the embedding layer and therefore is may not be necessary.
For inference, the layer could be built on-demand. For training, the behavior should be decided - whether removing the layer can be done or not.

Avoid random initialization for the model

The mamba model is first initialized before copying the weights from the pre-treined model.
On this first initialization, the parameters may get assigned random values which would normally be the case for a model that is going to get trained from scratch.

This initialization is slow (takes 10s+ in wasm) and a zeroed initialization is preferable.
Also, maybe this randomization could interfere with the model behavior itself, which would be a bug.

Support cuda (native) and wpgu (wasm)

For cuda, requires that dfdx support cuda for the underlying layers and tensor operations.
For wgpu, requires the same but also that the dfdx whole ecosystem support wgpu.

Then the app could show options to check and select different devices.

Check build requirements

Check what packages are required for building the project. If possible, try to avoid requiring extra packages.

  • esaxx-rs requires clang?
  • (TODO: confirm and list more requirements..)

Confirm the indexing for token processing are correct

The token processing may be behaving incorrectly in in relation to how it uses an index.

For example, if the input is on the form of QA:

Q: What is the capital of France?
A: Paris.

Q: How many months there are in a year?
A: 12 months.

Q: What is the capital of Canada?
A: 

When the prompt ends with [A][colon][space], the model continues in a really weird way.
So the first thing to check is if the token processor is correctly configured.

Another thing to check is the behavior from candle and also from the official python code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.