caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* AGI research using ocaml
@ 2010-03-13 10:29 Eray Ozkural
  2010-03-13 13:21 ` [Caml-list] " blue storm
  2010-03-13 15:02 ` Andre Nathan
  0 siblings, 2 replies; 18+ messages in thread
From: Eray Ozkural @ 2010-03-13 10:29 UTC (permalink / raw)
  To: caml-list

Hello there,

I recently did some interesting research on Artificial General
Intelligence using ocaml. Following the
research directions we had set with late Ray Solomonoff, I designed an
incremental machine
learning system. You can read about it on the AGI-2010 site:
http://agi-conf.org/2010/conference-schedule/

There is an extended abstract in the conference, which contains a
hyperlink to a draft of a
technical description of the program. If you're curious, go ahead and
read it, please.

Basically, this is an implementation of Adaptive Levin Search, the
most sophisticated of its kind that I
know of. And we have made significant algorithmic improvements to make
that happen, as you can
imagine.

There is similar research going on at Google, but they're taking a
different approach AFAICT. I
favor mine, because I'm trying to make a good practical approximation
of Solomonoff induction
which will serve as an AGI kernel in several cognitive architectures.
So, mathematical rigor comes
first.

I've used the ocs interpreter for interpreting Scheme programs. Thanks
to Ocaml, I was able to try
out several different search and update algorithms rather
effortlessly. And I think it didn't take much
more  than a month for me to finish the implementation. I wrote the
bulk of the program in a weekend or
two. Who knows, perhaps a future AGI system will have been written in ocaml.

Of course, all of this is possible due to the genius of Ray. He will
be sorely missed.

Now, a small question. What is the best way for me to use a caml
interpreter in ocaml? I have to
run millions of small caml programs, so startup latency can't be
tolerated. (For instance I can't execute
a unix process to interpret a program) I've decided that caml
represents more technological progress
than scheme, and I can definitely use the type system for better
search performance.

Best,

-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 10:29 AGI research using ocaml Eray Ozkural
@ 2010-03-13 13:21 ` blue storm
  2010-03-13 13:38   ` pierre.chambart
                     ` (2 more replies)
  2010-03-13 15:02 ` Andre Nathan
  1 sibling, 3 replies; 18+ messages in thread
From: blue storm @ 2010-03-13 13:21 UTC (permalink / raw)
  To: Eray Ozkural; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 2760 bytes --]

It is difficult to understand what you say with no previous knowledge of
your field (wich is probably not a common knowledge among OCaml hackers).
The fact that you paper is named "Stochastic Grammar Based Incremental
Machine Learning Using Scheme" doesn't help.

If I understand correctly (feel free to correct myself) :

1) your field of research is "automatic program generation to solve a set of
given tasks" : you generate random programs in a given language, with a
mathematic theory giving you probability distribution for various syntaxic
elements, until you find one that achieve your goal. You have a "learning
mechanism" that can reuse previous solution (such as declared functions) for
helping further tasks

2) You generate Scheme program fragments

3) Your algorithm/generator is written in OCaml, using the ocs Ocaml Scheme
interpreter to test your generated programs

4) You would like to generate OCaml program fragments instead of Scheme.
Your idea is that the type system, imposing more constraints on the legal
program, will reduce the search space and accelerate your generator.


In the example you give (square root, nand), you use only a tiny subset of a
general programming language features. Why did you choose to target the full
Scheme, instead of a minimalistic Lisp/Scheme subset ? It seems to me that
targeting a bigger language (wich additional feature your generator probably
doesn't know about anyway) will mainly incur an overhead on program
evaluation.
It is reasonable if you can access an already existing interpretor/evaluator
implementation that suit your need (reusing one of the available scheme
interpreters makes more sense than reimplementing one for scratch, maybe
even for a tiny subset of the langauge).
However, I'm not sure you can have something similar for OCaml : the only
used OCaml implementation is the INRIA implementation, wich has bytecode and
native compilers, but are not specially easy to invoke programmatically with
low startup times requirements. Perhaps the bytecode compiler would be quick
enough for your need, you should try.
I think the easiest way for you would be to implement a small language with
a ML typing system, and a tiny (but not algorithmically inefficient)
interpreter for it. On small program fragments, a small interpreter would
probably be much more interesting that calling an external tool. Besides,
you could design your small language accordingly to your generator
abilities.

You might also be interesting in minimal ML interpreters/compilers projects.
The two that I know of are :
- MiniML in Andrej Bauer "Programming language Zoo" :
http://andrej.com/plzoo/html/miniml.html
- MinCaml, a tiny ML compiler by Eijiro Sumii :
http://min-caml.sourceforge.net/index-e.html

[-- Attachment #2: Type: text/html, Size: 3007 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 13:21 ` [Caml-list] " blue storm
@ 2010-03-13 13:38   ` pierre.chambart
  2010-03-13 14:01     ` Eray Ozkural
  2010-03-13 15:48     ` Eray Ozkural
  2010-03-13 14:00   ` Eray Ozkural
  2010-03-13 15:38   ` [Caml-list] " Eliot Handelman
  2 siblings, 2 replies; 18+ messages in thread
From: pierre.chambart @ 2010-03-13 13:38 UTC (permalink / raw)
  To: caml-list


If I understand correctly the problem, that is generate code and execute
it quickly, the best
approach should be to use metaocaml. Moreover, your generated code will
be type safe.

http://www.metaocaml.org/
and the new implementation is available here:
http://okmij.org/ftp/ML/ber-metaocaml.tar.gz
-- 
Pierre


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 13:21 ` [Caml-list] " blue storm
  2010-03-13 13:38   ` pierre.chambart
@ 2010-03-13 14:00   ` Eray Ozkural
  2010-03-13 14:06     ` Basile Starynkevitch
  2010-03-14 19:38     ` Stefan Monnier
  2010-03-13 15:38   ` [Caml-list] " Eliot Handelman
  2 siblings, 2 replies; 18+ messages in thread
From: Eray Ozkural @ 2010-03-13 14:00 UTC (permalink / raw)
  To: blue storm; +Cc: caml-list

Hello BlueStorm,

I assume you're an AI of some sort ;)

On Sat, Mar 13, 2010 at 3:21 PM, blue storm <bluestorm.dylc@gmail.com> wrote:
> It is difficult to understand what you say with no previous knowledge of
> your field (wich is probably not a common knowledge among OCaml hackers).
> The fact that you paper is named "Stochastic Grammar Based Incremental
> Machine Learning Using Scheme" doesn't help.

It would be impossible for anybody to construct Algorithmic Probability Theory
on his own in little time. In fact, that's why I'm working on
incremental machine learning, for
there is no way one can simply come up with all the results in a
branch of science
from zero ground. We stand on the shoulders of the giants, which is the problem
I'm working on: general-purpose long-term memory.

> If I understand correctly (feel free to correct myself) :

Please go ahead, I'll do my best to clarify.

> 1) your field of research is "automatic program generation to solve a set of
> given tasks" : you generate random programs in a given language, with a
> mathematic theory giving you probability distribution for various syntaxic
> elements, until you find one that achieve your goal. You have a "learning
> mechanism" that can reuse previous solution (such as declared functions) for
> helping further tasks

Yes, although I don't generate random programs. Programs in the current system
are generated in a deterministic order. It's basically a search in the space of
leftmost-derivations of Scheme programming language. This is the induction step.

You are right, however, that program generation could be random.

I have a saying on the relation of all this to better known AI
research subjects:

Algorithmic Probability Theory is to Genetic Programming what
Statistical Learning Theory is to Neural Network Learning.

That is, it is a general principle of induction, that's known to have
very small generalization error. And there are proposed ways of
achieving this, like Adaptive Levin Search.

In a nutshell, you could say that it is an advanced kind of GP.

> 2) You generate Scheme program fragments

Yes.

> 3) Your algorithm/generator is written in OCaml, using the ocs Ocaml Scheme
> interpreter to test your generated programs

That's right.

> 4) You would like to generate OCaml program fragments instead of Scheme.
> Your idea is that the type system, imposing more constraints on the legal
> program, will reduce the search space and accelerate your generator.

Absolutely. For simpler function induction problems, I assume this
could even be done automatically by inducing type constraints over a
set of examples. Part of future research, I think. I am afraid I'll
have to read many programming language papers!

> In the example you give (square root, nand), you use only a tiny subset of a
> general programming language features. Why did you choose to target the full
> Scheme, instead of a minimalistic Lisp/Scheme subset ? It seems to me that
> targeting a bigger language (wich additional feature your generator probably
> doesn't know about anyway) will mainly incur an overhead on program
> evaluation.

Correct. But that was done to illustrate two (mainly obscure) points.
First, that we
can tackle a real-world programming language in its whole glory.
Second, actually recursive
problems are not required to know that the system is in principle of
doing such, for recursive
problems have been previously solved.

Obviously, future problems will feature recursion. For instance, Towers of Hanoi
was solved previously. It would be interesting to reproduce that
result in Scheme to
see if that solution depended on a specific (lucky) initial condition.

> It is reasonable if you can access an already existing interpretor/evaluator
> implementation that suit your need (reusing one of the available scheme
> interpreters makes more sense than reimplementing one for scratch, maybe
> even for a tiny subset of the langauge).

Yes.

> However, I'm not sure you can have something similar for OCaml : the only
> used OCaml implementation is the INRIA implementation, wich has bytecode and
> native compilers, but are not specially easy to invoke programmatically with
> low startup times requirements. Perhaps the bytecode compiler would be quick
> enough for your need, you should try.

Compilation would probably be overkill. The evaluation shouldn't make
any unnecessary
syscall's, access files, etc.

> I think the easiest way for you would be to implement a small language with
> a ML typing system, and a tiny (but not algorithmically inefficient)
> interpreter for it. On small program fragments, a small interpreter would
> probably be much more interesting that calling an external tool. Besides,
> you could design your small language accordingly to your generator
> abilities.

Yes, something like that is done in ADATE IIRC.

> You might also be interesting in minimal ML interpreters/compilers projects.
> The two that I know of are :
> - MiniML in Andrej Bauer "Programming language Zoo" :
> http://andrej.com/plzoo/html/miniml.html
> - MinCaml, a tiny ML compiler by Eijiro Sumii :
> http://min-caml.sourceforge.net/index-e.html

Thank you.

Best Regards,

-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 13:38   ` pierre.chambart
@ 2010-03-13 14:01     ` Eray Ozkural
  2010-07-29 22:44       ` Eray Ozkural
  2010-03-13 15:48     ` Eray Ozkural
  1 sibling, 1 reply; 18+ messages in thread
From: Eray Ozkural @ 2010-03-13 14:01 UTC (permalink / raw)
  To: pierre.chambart; +Cc: caml-list

Hi there,

On Sat, Mar 13, 2010 at 3:38 PM, pierre.chambart
<pierre.chambart@laposte.net> wrote:
>
> If I understand correctly the problem, that is generate code and execute
> it quickly, the best
> approach should be to use metaocaml. Moreover, your generated code will
> be type safe.
>
> http://www.metaocaml.org/
> and the new implementation is available here:
> http://okmij.org/ftp/ML/ber-metaocaml.tar.gz

Yes, that is my problem exactly. And type-safety is beneficial for
both humans and AI's! It helps us avoid silly programming errors!

I shall have a closer look. Thanks for the reference.

Best,

-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 14:00   ` Eray Ozkural
@ 2010-03-13 14:06     ` Basile Starynkevitch
  2010-03-13 14:58       ` Eray Ozkural
  2010-03-14 19:38     ` Stefan Monnier
  1 sibling, 1 reply; 18+ messages in thread
From: Basile Starynkevitch @ 2010-03-13 14:06 UTC (permalink / raw)
  To: Eray Ozkural; +Cc: blue storm, caml-list

Eray Ozkural wrote:
> Hello BlueStorm,
> 
> I assume you're an AI of some sort ;)
> 
> On Sat, Mar 13, 2010 at 3:21 PM, blue storm <bluestorm.dylc@gmail.com> wrote:
>> It is difficult to understand what you say with no previous knowledge of
>> your field (wich is probably not a common knowledge among OCaml hackers).
>> The fact that you paper is named "Stochastic Grammar Based Incremental
>> Machine Learning Using Scheme" doesn't help.
> 
> It would be impossible for anybody to construct Algorithmic Probability Theory
> on his own in little time. In fact, that's why I'm working on
> incremental machine learning, for
> there is no way one can simply come up with all the results in a
> branch of science
> from zero ground. We stand on the shoulders of the giants, which is the problem
> I'm working on: general-purpose long-term memory.
> 

Sorry for the off-topic remark, but you might be interested by Jacques 
Pitrat's work, e.g. his "Artificial Being" book (March 2009, Wiley) 
http://www.iste.co.uk/index.php?f=a&ACTION=View&id=257 and his 
MALICE/CAIA system on http://pagesperso-orange.fr/jacques.pitrat/

Regards.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 14:06     ` Basile Starynkevitch
@ 2010-03-13 14:58       ` Eray Ozkural
  2010-03-13 15:36         ` Basile Starynkevitch
  0 siblings, 1 reply; 18+ messages in thread
From: Eray Ozkural @ 2010-03-13 14:58 UTC (permalink / raw)
  To: Basile Starynkevitch; +Cc: blue storm, caml-list

On Sat, Mar 13, 2010 at 4:06 PM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
>
> Sorry for the off-topic remark, but you might be interested by Jacques
> Pitrat's work, e.g. his "Artificial Being" book (March 2009, Wiley)
> http://www.iste.co.uk/index.php?f=a&ACTION=View&id=257 and his MALICE/CAIA
> system on http://pagesperso-orange.fr/jacques.pitrat/

Hello Basile,

Indeed my goal is the same as Pitrat's, I wish to construct an
automated scientist/engineer. I am not so much interested in the
redundancy of everday human life which we have enough of. But it would
be really interesting if it could solve some problems, come up with a
theory to explain some experimental results, or write programs for me!
So, it's kind of a computer-aid for the scientist, I suppose.

How to make it relevant to the list? Well, that's easy. In this new
breed of AI research we actually need both 1) symbolic processing 2)
efficient algorithms and complex data structures. Ocaml fills the both
niches rather nicely. Whether I need to implement a CFG, a theorem
prover, a graph algorithm, or a data mining algorithm, ocaml is there
for me. And that's great because I can keep everything in one
language. My only problem right now is the lack of proper GPU support.
Except that, it's perfect. MPI will be good enough for
multicore/distributed code.

Best,

-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 10:29 AGI research using ocaml Eray Ozkural
  2010-03-13 13:21 ` [Caml-list] " blue storm
@ 2010-03-13 15:02 ` Andre Nathan
  2010-03-13 15:39   ` Eray Ozkural
  1 sibling, 1 reply; 18+ messages in thread
From: Andre Nathan @ 2010-03-13 15:02 UTC (permalink / raw)
  To: Eray Ozkural; +Cc: caml-list

Eray,

You could consider using the Toploop module to interpret an ocaml
program; for example,

  Toploop.use_silently Format.std_formatter "foo.ml".

This is what I do in OSpec to run the specification files. I haven't
measured the overhead of using this module but at least you don't need
to fork a process to run each of your programs.

HTH,
Andre


On Sat, 2010-03-13 at 12:29 +0200, Eray Ozkural wrote:
> Hello there,
> 
> I recently did some interesting research on Artificial General
> Intelligence using ocaml. Following the
> research directions we had set with late Ray Solomonoff, I designed an
> incremental machine
> learning system. You can read about it on the AGI-2010 site:
> http://agi-conf.org/2010/conference-schedule/
> 
> There is an extended abstract in the conference, which contains a
> hyperlink to a draft of a
> technical description of the program. If you're curious, go ahead and
> read it, please.
> 
> Basically, this is an implementation of Adaptive Levin Search, the
> most sophisticated of its kind that I
> know of. And we have made significant algorithmic improvements to make
> that happen, as you can
> imagine.
> 
> There is similar research going on at Google, but they're taking a
> different approach AFAICT. I
> favor mine, because I'm trying to make a good practical approximation
> of Solomonoff induction
> which will serve as an AGI kernel in several cognitive architectures.
> So, mathematical rigor comes
> first.
> 
> I've used the ocs interpreter for interpreting Scheme programs. Thanks
> to Ocaml, I was able to try
> out several different search and update algorithms rather
> effortlessly. And I think it didn't take much
> more  than a month for me to finish the implementation. I wrote the
> bulk of the program in a weekend or
> two. Who knows, perhaps a future AGI system will have been written in ocaml.
> 
> Of course, all of this is possible due to the genius of Ray. He will
> be sorely missed.
> 
> Now, a small question. What is the best way for me to use a caml
> interpreter in ocaml? I have to
> run millions of small caml programs, so startup latency can't be
> tolerated. (For instance I can't execute
> a unix process to interpret a program) I've decided that caml
> represents more technological progress
> than scheme, and I can definitely use the type system for better
> search performance.
> 
> Best,
> 



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 14:58       ` Eray Ozkural
@ 2010-03-13 15:36         ` Basile Starynkevitch
  0 siblings, 0 replies; 18+ messages in thread
From: Basile Starynkevitch @ 2010-03-13 15:36 UTC (permalink / raw)
  To: Eray Ozkural; +Cc: caml-list

Eray Ozkural wrote: My only problem right now is the lack of proper GPU 
support.

The OpenGPU http://opengnu.net/ project which just has started would in 
principle add interface to GPU processing (perhaps thru OpenCL, e.g. by 
interfacing some OpenCL or Cuda libraries to Ocaml) so provide such 
features to Ocaml.


But the project has just started, and probably will have first results 
in a year.

I will work within OpenGPU, but with GCC (using MELT, a lispy dialect to 
code GCC plugins in), so not directly related to Ocaml. The Ocaml work 
will be from LIP6 people (like E.Chailloux).

cheers

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 13:21 ` [Caml-list] " blue storm
  2010-03-13 13:38   ` pierre.chambart
  2010-03-13 14:00   ` Eray Ozkural
@ 2010-03-13 15:38   ` Eliot Handelman
  2010-03-13 15:41     ` Eray Ozkural
  2 siblings, 1 reply; 18+ messages in thread
From: Eliot Handelman @ 2010-03-13 15:38 UTC (permalink / raw)
  To: blue storm; +Cc: Eray Ozkural, caml-list

blue storm wrote:
>
>
> 1) your field of research is "automatic program generation to solve a 
> set of given tasks" : you generate random programs in a given 
> language, with a mathematic theory giving you probability distribution 
> for various syntaxic elements, until you find one that achieve your 
> goal. You have a "learning mechanism" that can reuse previous solution 
> (such as declared functions) for helping further tasks
>
> 2) You generate Scheme program fragments
>
> 3) Your algorithm/generator is written in OCaml, using the ocs Ocaml 
> Scheme interpreter to test your generated programs
>
> 4) You would like to generate OCaml program fragments instead of 
> Scheme. Your idea is that the type system, imposing more constraints 
> on the legal program, will reduce the search space and accelerate your 
> generator.

If this description is correct (I haven't followed the whole discussion) 
then check out the adate system, which generates programs
in a subset of SML:

http://www-ia.hiof.no/~rolando/

-- eliot


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 15:02 ` Andre Nathan
@ 2010-03-13 15:39   ` Eray Ozkural
  2010-03-13 15:56     ` Andre Nathan
  0 siblings, 1 reply; 18+ messages in thread
From: Eray Ozkural @ 2010-03-13 15:39 UTC (permalink / raw)
  To: Andre Nathan; +Cc: caml-list

Hello Andre,

Thanks for the suggestion. Perhaps it is possible to use the toplevel
on a string based file? Then, there wouldn't be the I/O overhead at
least, just buffering overhead. For some reason I can't find the
documentation for this. It's weird. :/ I used to write ocaml libraries
back in 2002 and still not an ocaml hacker! Heh :)

On Sat, Mar 13, 2010 at 5:02 PM, Andre Nathan <andre@digirati.com.br> wrote:
> Eray,
>
> You could consider using the Toploop module to interpret an ocaml
> program; for example,
>
>  Toploop.use_silently Format.std_formatter "foo.ml".
>
> This is what I do in OSpec to run the specification files. I haven't
> measured the overhead of using this module but at least you don't need
> to fork a process to run each of your programs.
>
> HTH,
> Andre


-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 15:38   ` [Caml-list] " Eliot Handelman
@ 2010-03-13 15:41     ` Eray Ozkural
  0 siblings, 0 replies; 18+ messages in thread
From: Eray Ozkural @ 2010-03-13 15:41 UTC (permalink / raw)
  To: eliot; +Cc: blue storm, caml-list

On Sat, Mar 13, 2010 at 5:38 PM, Eliot Handelman <eliot@colba.net> wrote:
>
> If this description is correct (I haven't followed the whole discussion)
> then check out the adate system, which generates programs
> in a subset of SML:
>
> http://www-ia.hiof.no/~rolando/

Yes, ADATE is relevant, but this is errr... significantly different
from ADATE, so I can't just use it for my needs. ADATE does function
induction of course, it's one of the first programs that implemented a
proper program search.

Best,

-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 13:38   ` pierre.chambart
  2010-03-13 14:01     ` Eray Ozkural
@ 2010-03-13 15:48     ` Eray Ozkural
  2010-03-13 16:00       ` blue storm
  1 sibling, 1 reply; 18+ messages in thread
From: Eray Ozkural @ 2010-03-13 15:48 UTC (permalink / raw)
  To: pierre.chambart; +Cc: caml-list

BTW, I think I left out an important implementation detail.

To implement Levin Search using ocs, I had to hack the ocs interpreter
so it counted Scheme Execution Cycles.

Kind of like a cheap runtime profiling. Could I use a cpu timer
instead? Yes, certainly, but I did that.

At any rate, I need to be able to terminate the execution of the
interpreter when a specific time limit is reached. In ocs, I threw an
exception when a cycle limit was reached. How should I do that when
using meta ocaml and what would give me the least overhead? Should I
use a timer interrupt? Would it work out at a nanosecond level?

Please excuse my ignorance. I've had a lot of trouble working on
absolutely obsolete C++ code for some not-so-useful research projects,
so I couldn't have much time to work on ocaml, I think I've forgotten
much :(

Best,

On Sat, Mar 13, 2010 at 3:38 PM, pierre.chambart
<pierre.chambart@laposte.net> wrote:
>
> If I understand correctly the problem, that is generate code and execute
> it quickly, the best
> approach should be to use metaocaml. Moreover, your generated code will
> be type safe.
>
> http://www.metaocaml.org/
> and the new implementation is available here:
> http://okmij.org/ftp/ML/ber-metaocaml.tar.gz
> --
> Pierre
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 15:39   ` Eray Ozkural
@ 2010-03-13 15:56     ` Andre Nathan
  0 siblings, 0 replies; 18+ messages in thread
From: Andre Nathan @ 2010-03-13 15:56 UTC (permalink / raw)
  To: Eray Ozkural; +Cc: caml-list

On Sat, 2010-03-13 at 17:39 +0200, Eray Ozkural wrote:
> Thanks for the suggestion. Perhaps it is possible to use the toplevel
> on a string based file? Then, there wouldn't be the I/O overhead at
> least, just buffering overhead. For some reason I can't find the
> documentation for this. It's weird. :/ I used to write ocaml libraries
> back in 2002 and still not an ocaml hacker! Heh :)

Eray,

Yes, you can find an "eval" function here, which uses
Toploop.execute_phrase:

  http://pleac.sourceforge.net/pleac_ocaml/strings.html#AEN68

The docs for Toploop are in toplevel/toploop.mli in the OCaml source.

Andre


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 15:48     ` Eray Ozkural
@ 2010-03-13 16:00       ` blue storm
  2010-03-13 16:57         ` Eray Ozkural
  0 siblings, 1 reply; 18+ messages in thread
From: blue storm @ 2010-03-13 16:00 UTC (permalink / raw)
  To: Eray Ozkural; +Cc: pierre.chambart, caml-list

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

If you control the code, the easiest way is to :
- add runtime profiling functions directly inside the generated code (for
example, one before each function call and sequencing construct)
- hardcode into your profiling functions the fact that, after a certain
number of steps, excecution should be aborted.

Example :

  let count = ref 0
  let max_count = 100 (* you choose that constant during generation *)
  exception Terminated
  let step () =
    incr count;
    if !count > max_count then raise Terminated

  (* generated code *)
  let code () =
    ... ; step (); ...; step () ; ...

You could probably also have max_count passed as a parameter at execution
time (allowing you to execute the same generated code with different time
limits).

[-- Attachment #2: Type: text/html, Size: 817 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 16:00       ` blue storm
@ 2010-03-13 16:57         ` Eray Ozkural
  0 siblings, 0 replies; 18+ messages in thread
From: Eray Ozkural @ 2010-03-13 16:57 UTC (permalink / raw)
  To: blue storm; +Cc: pierre.chambart, caml-list

Yes, but this would incur generation overhead. A lot of it if you
consider that I generate on the order of millions of tiny programs.
Not sure if it's a good idea. Any chance I can get a precise timer
interrupt to work gracefully?

The other option seems to be to hack meta ocaml so that I can get the
kind of timer exception I need.

Cheers,

On Sat, Mar 13, 2010 at 6:00 PM, blue storm <bluestorm.dylc@gmail.com> wrote:
> If you control the code, the easiest way is to :
> - add runtime profiling functions directly inside the generated code (for
> example, one before each function call and sequencing construct)
> - hardcode into your profiling functions the fact that, after a certain
> number of steps, excecution should be aborted.
>
> Example :
>
>   let count = ref 0
>   let max_count = 100 (* you choose that constant during generation *)
>   exception Terminated
>   let step () =
>     incr count;
>     if !count > max_count then raise Terminated
>
>   (* generated code *)
>   let code () =
>     ... ; step (); ...; step () ; ...
>
> You could probably also have max_count passed as a parameter at execution
> time (allowing you to execute the same generated code with different time
> limits).
>



-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: AGI research using ocaml
  2010-03-13 14:00   ` Eray Ozkural
  2010-03-13 14:06     ` Basile Starynkevitch
@ 2010-03-14 19:38     ` Stefan Monnier
  1 sibling, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2010-03-14 19:38 UTC (permalink / raw)
  To: caml-list

>> 4) You would like to generate OCaml program fragments instead of Scheme.
>> Your idea is that the type system, imposing more constraints on the legal
>> program, will reduce the search space and accelerate your generator.
> Absolutely.  For simpler function induction problems, I assume this
> could even be done automatically by inducing type constraints over a
> set of examples.  Part of future research, I think.  I am afraid I'll
> have to read many programming language papers!

Depending on how you want to use types, it can help, but not
necessarily:

If you manage to use types to restrict your search, then that's great,
since your programs will be properly typed by construction (and the host
language may even know that, e.g. using GADTs or something equivalent)
and you may indeed be able to interpret them faster.

But if you don't, then you end up with programs which may or may not be
properly typed, in which case types will allow you to reject programs
before running them, but at the cost of having to type-check every
program.  So if the run time of each program is short compared to the
program's size, it may end up more costly to type-check the code than to
just run it.


        Stefan


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Caml-list] AGI research using ocaml
  2010-03-13 14:01     ` Eray Ozkural
@ 2010-07-29 22:44       ` Eray Ozkural
  0 siblings, 0 replies; 18+ messages in thread
From: Eray Ozkural @ 2010-07-29 22:44 UTC (permalink / raw)
  To: pierre.chambart; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]

On Sat, Mar 13, 2010 at 5:01 PM, Eray Ozkural <examachine@gmail.com> wrote:

> Hi there,
>
> On Sat, Mar 13, 2010 at 3:38 PM, pierre.chambart
> <pierre.chambart@laposte.net> wrote:
> >
> > If I understand correctly the problem, that is generate code and execute
> > it quickly, the best
> > approach should be to use metaocaml. Moreover, your generated code will
> > be type safe.
> >
> > http://www.metaocaml.org/
> > and the new implementation is available here:
> > http://okmij.org/ftp/ML/ber-metaocaml.tar.gz
>


I've taken a look at the 002 release of the BER fork. With some small
modification to labltk dir I could get metaocaml to compile and run. AFAICT,
there is no native code support for x64. Are there any plans to upgrade to
3.12 and x64?

Best,

-- 
Eray Ozkural

[-- Attachment #2: Type: text/html, Size: 1342 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2010-07-29 22:44 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-13 10:29 AGI research using ocaml Eray Ozkural
2010-03-13 13:21 ` [Caml-list] " blue storm
2010-03-13 13:38   ` pierre.chambart
2010-03-13 14:01     ` Eray Ozkural
2010-07-29 22:44       ` Eray Ozkural
2010-03-13 15:48     ` Eray Ozkural
2010-03-13 16:00       ` blue storm
2010-03-13 16:57         ` Eray Ozkural
2010-03-13 14:00   ` Eray Ozkural
2010-03-13 14:06     ` Basile Starynkevitch
2010-03-13 14:58       ` Eray Ozkural
2010-03-13 15:36         ` Basile Starynkevitch
2010-03-14 19:38     ` Stefan Monnier
2010-03-13 15:38   ` [Caml-list] " Eliot Handelman
2010-03-13 15:41     ` Eray Ozkural
2010-03-13 15:02 ` Andre Nathan
2010-03-13 15:39   ` Eray Ozkural
2010-03-13 15:56     ` Andre Nathan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).