HNHacker News
TopNewBestAskShowJobs

imaginaryspaces

9 karma · joined February 4, 2025

submissionscomments
imaginaryspaces··on My Co-Founder threw away 90% of the code I wrote
Fair enough! Thats a good point :)
imaginaryspaces··on My Co-Founder threw away 90% of the code I wrote
Thanks!
imaginaryspaces··on My Co-Founder threw away 90% of the code I wrote
Perhaps, shall check with him! But this is only one example, there’s a lot of other places as well. In case you’re interested to see more the project we’re working on is https://github.com/plexe-ai/smolmodels
imaginaryspaces··on My Co-Founder threw away 90% of the code I wrote
No, he’s from a Python background :)
imaginaryspaces··on My Co-Founder threw away 90% of the code I wrote
Good point! The initial 60% of the code was thought out but with time passing, the urge to launch quicker became more important leading:)
imaginaryspaces··on My Co-Founder threw away 90% of the code I wrote
You caught me trying to escape some embarrassment. Here's an example:

To set some context: The code handles isolated execution of machine learning code.

Original version:

    def run_code(code, timeout=3600):
        try:
            p = Process(target=exec, args=(code,))
            p.start()
            p.join(timeout)
            if p.is_alive():
                p.terminate()
                return "Timeout"
            return "Success"
        except Exception as e:
            return f"Failed: {str(e)}"
New version:

    class ProcessExecutor(Executor):
        def __init__(self, execution_id: str, code: str, 
                     working_dir: Path, dataset: pd.DataFrame, 
                     timeout: int = 3600):
            super().__init__(code, timeout)
            self.working_dir = Path(working_dir).resolve() / execution_id
            self.working_dir.mkdir(parents=True, exist_ok=True)
            self.dataset = dataset

        def run(self) -> ExecutionResult:
            start_time = time.time()
            code_file: Path = self.working_dir / self.code_file_name
            with open(code_file, "w") as f:
                f.write(self.code)
                
            try:
                process = subprocess.Popen(
                    [sys.executable, str(code_file)],
                    stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE,
                    cwd=str(self.working_dir),
                    text=True,
                )
                stdout, stderr = process.communicate(timeout=self.timeout)
                return ExecutionResult(
                    term_out=[stdout],
                    exec_time=time.time() - start_time,
                    model_artifacts=self._collect_artifacts(),
                    performance=extract_performance(stdout),
                )
            except subprocess.TimeoutExpired:
                process.kill()
                return ExecutionResult(
                    term_out=[],
                    exec_time=self.timeout,
                    exception=TimeoutError(
                        f"Execution exceeded {self.timeout}s timeout"
                    ),
                )
imaginaryspaces··on My Co-Founder threw away 90% of the code I wrote
Unfortunately the old version is long gone now but I can show you the current version :)
imaginaryspaces··on My Co-Founder threw away 90% of the code I wrote
Thank you! There’s absolutely no reason for me to rant since we have a solid foundation to build on now :)
imaginaryspaces··on Show HN: Smolmodels – open-source tool to build ML models using natural language
As of now (v0.4.0), the library expects a structured/tabular input (think pandas DataFrame). So you could use it for things like transaction data, insurance records, anything that fits in a "table".

However, the concept generalises to other data types very naturally, and we plan to add support for things like images, audio etc very soon :)

imaginaryspaces··on Show HN: Smolmodels – open-source tool to build ML models using natural language
Thanks!
imaginaryspaces··on Show HN: Smolmodels – open-source tool to build ML models using natural language
Not yet, though we plan to add that feature soon-ish! As of 0.4.0, with this tool you can use LLMs to build non-LLM models for your ML use cases.

For example: you have an ecommerce site and want to rank relevant products for your users. You want to launch a prototype quickly. You could use ChatGPT as your ranker ("rank products for this user ..."), or you could use smolmodels to generate a more lightweight ranking model like a smaller neural net, etc.